明显是无良心的数学round= =

1000 Zball in Tina Town

BestCoder Round #51 (div.2)-LMLPHP

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#define PAU putchar(' ')
#define ENT putchar('\n')
#define Safe 6
using namespace std;
typedef long long LL;
const int maxn=+;
LL gcd(LL a, LL b){
return b == ? a : gcd(b, a % b);
}
LL n, x, mx;
LL mul(LL a, LL b, LL p){
LL tmp = (a * b - (LL)((long double)a / p * b + 1e-) * p);
return tmp < ? tmp + p : tmp;
}
LL pow(LL a, LL b, LL p){
LL ans = ; a %= p;
for(LL i = b; i; i >>= , a = mul(a, a, p))
if(i & ) ans = mul(ans, a, p);
return ans;
}
bool check(LL a, LL n, LL r, LL s){
LL ans = pow(a, r, n), p = ans;
for(int i = ; i <= s; i ++){
ans = mul(ans, ans, n);
if(ans == && p != && p != n - ) return true;
p = ans;
}
if(ans != )return true;
return false;
}
bool MR(LL n){
if(n <= ) return false;
if(n == ) return true;
if(n % == ) return false;
LL r = n - , s = ;
while(r % == ) r /= , s ++;
for(int i = ; i < Safe; i ++)
if(check(rand() % (n - ) + , n, r, s)) return false;
return true;
}
inline LL read(){
LL x=;bool sig=;char ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')sig=;
for(;isdigit(ch);ch=getchar())x=*x+ch-'';
return sig?x:-x;
}
inline void write(LL x){
if(x==){putchar('');return;}if(x<)putchar('-'),x=-x;
int len=;static LL buf[];while(x)buf[len++]=x%,x/=;
for(int i=len-;i>=;i--)putchar(buf[i]+'');return;
}
int T;
int main(){
T=read();LL x;
while(T--){
x=read();
if(x==){write();ENT;continue;}
if(x==){write();ENT;continue;}
if(MR(x))write(x-),ENT;
else write(),ENT;
}
// for(LL x=1;x<=100;x++){
// LL fac=1;
// for(int i=2;i<x;i++)fac=fac*i%x;write(x);PAU;write(fac);ENT;
// }
return ;
}

然后这道题全场都被至少扣了一分,不明觉厉= =

1001 Infoplane in Tina Town

BestCoder Round #51 (div.2)-LMLPHP

显然不可写= =div1都没有人过= =

04-27 02:46