洛谷数学题:考察异或知识(数据输入多所以拉过来当速读写模板)
#include<bits/stdc++.h>
#include<unordered_set>
#define mem(a,b) memset(a,b,sizeof a)
#define cinios (ios::sync_with_stdio(false),cin.tie(0),cout.tie(0))
#define sca scanf
#define pri printf
#define ul u << 1
#define ur u << 1 | 1
//#pragma GCC optimize(2)
using namespace std;
//inline void read(int& x) { x = 0; int f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch - '0'); ch = getchar(); } x *= f; }
//void write(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) write(x / 10); putchar(x % 10 + '0'); }
//放上面不用占位置,write不开inline,因为并联函数里不要有递归或大的循环,自行百度
typedef long long ll;
typedef pair<int, int> PII;
const int N = 110, M = N * N * 2;
int INF = 0x3f3f3f3f, mod = 1e9;
int n, m, k, T, S;
void inline read(int& x) { //传入地址直接修改
x = 0;
int f = 1;//特判负数
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')f = -1;//有负号即负数
c = getchar();
}
while (c >= '0' && c <= '9')
x = x * 10 + (c - '0'), c = getchar();
x *= f;
}
void inline write(int x) {
if (x < 0) putchar('-'), x = -x;//特判负数
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
int main() {
read(n);
int ans = 0, t;
for (int i = 0; i < n; i++) {
read(t);
ans ^= t;
}
write(ans);
return 0;
}
用scanf、printf的时间
神奇的快速读写(快了4、5倍)
__int128(超越long long的存储)
跟快读写非常相像,但__int128只能在Linux系统中编译,这意味着在大部分编程工具中是会编译失败的…
但,你只要在保证正确之后再更改类型不就好了吗
#include <bits/stdc++.h>
using namespace std;
void scan(__int128 &x)//输入
{
x=0;int f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
x*=f;
}
void _print(__int128 x)
{
if(x>9) _print(x/10);
putchar(x%10 + '0');
}
void print(__int128 x)//输出
{
if(x<0)
{
x=-x;
putchar('-');
}
_print(x);
}