提交记录 3139


用户 题目 状态 得分 用时 内存 语言 代码长度
wys 1000i. 【传统题】 A+B Problem Accepted 100 54.8 us 40 KB C++ 2.40 KB
提交时间 评测时间
2018-07-08 21:24:17 2020-07-31 21:11:46
// new and delete test
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#define PI 3.14159265358979323846

template <class T>
inline void swap(T &a, T &b) {
	T t = a;
	a = b, b = t;
}

namespace IO {
	const int BUF_SIZE = 1 << 15;
	char in_buf[BUF_SIZE], out_buf[BUF_SIZE];
	char *p_in_buf = in_buf + BUF_SIZE;
	char *p_out_buf = out_buf;
	
	
	inline char get_char() {
		if (p_in_buf == in_buf + BUF_SIZE) {
			fread(in_buf, 1, BUF_SIZE, stdin), p_in_buf = in_buf;
		}
		return *(p_in_buf++);
	}
	
	inline void put_char(char x) {
		if (p_out_buf == out_buf + BUF_SIZE) {
			fwrite(out_buf, 1, BUF_SIZE, stdout), p_out_buf = out_buf;
		}
		*(p_out_buf++) = x;
	}
	
	inline void flush() {
		if (p_out_buf != out_buf) {
			fwrite(out_buf, 1, p_out_buf - out_buf, stdout);
			p_out_buf = out_buf;
		}
	}
}

#define getchar() IO::get_char()
#define putchar(x) IO::put_char(x)

inline int getint() {
	int x = 0;
	char c = getchar();
	while (c <= 32) c = getchar();
	int f = 1;
	if (c == '-') f = -1, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * f;
}

template <class T>
inline void _putint(T x) {
	return x ? _putint(x / 10), putchar(48 + x % 10), void() : void();
}

template <class T>
inline void putint(T x) {
	if (x < 0) return putchar('-'), putint(-x), void();
	return x == 0 ? putchar('0'), void() : _putint(x), void();
}

inline void getline(char *s) {
	char c = getchar();
	while (c == '\n') c = getchar();
	while (c != '\n') *(s++) = c, c = getchar();
	*s = 0;
}

// ==== header ====

int *pInt, *qInt, *pBuf, *qBuf;

int main() {
	
	unsigned char buf[sizeof(int)*2] ;
	
	// [test]
    // placement new in buf
    pInt = new (buf) int(3);

    qInt = new (buf + sizeof (int)) int(5);
    pBuf = (int*)(buf+0) ;
    qBuf = (int*) (buf + sizeof(int));
	
	int n = getint();
	
	for (int i = 1; i <= n; i++) {
		int a, b;
		a = getint();
		b = getint();
		int f1 = a > 0 ? 1 : -1;
		int f2 = b > 0 ? 1 : -1;
		a *= f1, b *= f2;
		std::vector<int> v(500);
		for (int j = 0; j < a / 10000000; j++) {
			if (f1 > 0) {
				v.push_back(b);
			} else {
				v.pop_back();
			}
		}
		for (int j = 0; j < b / 10000000; j++) {
			if (f2 > 0) {
				v.push_back(a);
			} else {
				v.pop_back();
			}
		}
		int ans = (-500 + v.size()) * 10000000;
		ans += f1 * (a % 10000000);
		ans += f2 * (b % 10000000);
		putint(ans);
		putchar('\n');
	}
	
	IO::flush();
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #154.8 us40 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-11-21 20:43:57 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠