#pragma GCC optimize("Ofast,unroll-loops")
#include <cstdio>
#pragma GCC optimize(3)
namespace yaCachedTextIO
{
template <std::size_t bufferLength = 1 << 20>
class cachedTextInput
{
std::FILE *inputFile;
char buffer[bufferLength], *bufferStart, *bufferEnd, currentCharacter;
bool signedFlag;
inline void _gc()
{
if (bufferStart == bufferEnd)
{
bufferEnd = (bufferStart = buffer) + std::fread(buffer, 1, bufferLength, inputFile);
currentCharacter = bufferStart == bufferEnd ? EOF : *bufferStart++;
}
else
currentCharacter = *bufferStart++;
}
public:
inline cachedTextInput(std::FILE *_inputFile = stdin) : inputFile(_inputFile), bufferStart(NULL), bufferEnd(NULL) {}
template <typename unsignedIntegerType>
inline void getUnsignedDecimalInteger(register unsignedIntegerType &x)
{
x = 0;
_gc();
while (currentCharacter < '0' || currentCharacter > '9')
_gc();
while ('0' <= currentCharacter && currentCharacter <= '9')
{
x = (x << 1) + (x << 3) + (currentCharacter ^ '0');
_gc();
}
}
template <typename signedIntegerType>
inline void getSignedDecimalInteger(register signedIntegerType &x)
{
x = 0;
signedFlag = false;
_gc();
while (currentCharacter < '0' || currentCharacter > '9')
{
if (currentCharacter == '-')
signedFlag = true;
_gc();
}
while ('0' <= currentCharacter && currentCharacter <= '9')
{
x = (x << 1) + (x << 3) + (currentCharacter ^ 48);
_gc();
}
if (signedFlag)
x = -x;
}
};
template <std::size_t bufferLength = 1 << 20, std::size_t temporaryBufferLength = 256>
class cachedTextOutput
{
std::FILE *outputFile;
char buffer[bufferLength], *bufferLimit, *bufferEnd;
char temporaryBuffer[temporaryBufferLength], *temporaryBufferLimit, *temporaryBufferEnd;
inline void _flush()
{
std::fwrite(buffer, 1, bufferEnd - buffer, outputFile);
bufferEnd = buffer;
}
inline void _pc(register const char ¤tCharacter)
{
if (bufferEnd == bufferLimit)
_flush();
*bufferEnd++ = currentCharacter;
}
inline void _flushTmp()
{
while (temporaryBufferEnd != temporaryBuffer)
_pc(*--temporaryBufferEnd);
}
public:
inline cachedTextOutput(std::FILE *_outputFile = stdout) : outputFile(_outputFile), bufferEnd(buffer), bufferLimit(buffer + bufferLength), temporaryBufferEnd(temporaryBuffer), temporaryBufferLimit(temporaryBuffer + temporaryBufferLength) {}
inline ~cachedTextOutput()
{
_flush();
}
inline void putCharacter(const char &c)
{
_pc(c);
}
template <typename unsignedIntegerType>
inline void putUnsignedDecimalInteger(register unsignedIntegerType x)
{
unsignedIntegerType tmp;
do
{
tmp = x / 10;
*temporaryBufferEnd++ = ((x - ((tmp << 1) + (tmp << 3))) ^ '0');
x = tmp;
} while (x);
_flushTmp();
}
template <typename signedIntegerType>
inline void putSignedDecimalInteger(register signedIntegerType x)
{
if (x < 0)
{
x = -x;
_pc('-');
}
putUnsignedDecimalInteger(x);
}
inline void putSpace()
{
_pc(' ');
}
inline void putLine()
{
_pc('\n');
}
};
};
namespace yaCode
{
using yaCachedTextIO::cachedTextInput;
using yaCachedTextIO::cachedTextOutput;
};
using namespace yaCode;
cachedTextInput<1500> _cachedTextInput;
#define in(x) _cachedTextInput.getSignedDecimalInteger((x))
cachedTextOutput<1500, 10> _cachedTextOutput;
#define ou(x) _cachedTextOutput.putSignedDecimalInteger((x))
#define ousp(x) _cachedTextOutput.putSignedDecimalInteger((x)), _cachedTextOutput.putSpace()
#define ouln _cachedTextOutput.putLine()
int main()
{
register int n, a, b;
in(n);
while (n--)
{
in(a);
in(b);
ou(a + b);
ouln;
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 15.43 us | 28 KB | Accepted | Score: 100 | 显示更多 |