BestCoder Round #51 (div.2)

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

1000 Zball in Tina Town

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<stack>
 6 #include<queue>
 7 #include<cstring>
 8 #define PAU putchar(' ')
 9 #define ENT putchar('\n')
10 #define Safe 6
11 using namespace std;
12 typedef long long LL;
13 const int maxn=100000+10;
14 LL gcd(LL a, LL b){
15     return b == 0 ? a : gcd(b, a % b);
16 }
17 LL n, x, mx;
18 LL mul(LL a, LL b, LL p){
19     LL tmp = (a * b - (LL)((long double)a / p * b + 1e-8) * p);
20     return tmp < 0 ? tmp + p : tmp;
21 }
22 LL pow(LL a, LL b, LL p){
23     LL ans = 1; a %= p;
24     for(LL i = b; i; i >>= 1, a = mul(a, a, p))
25         if(i & 1) ans = mul(ans, a, p);
26     return ans;
27 }
28 bool check(LL a, LL n, LL r, LL s){
29     LL ans = pow(a, r, n), p = ans;
30     for(int i = 1; i <= s; i ++){
31         ans = mul(ans, ans, n);
32         if(ans == 1 && p != 1 && p != n - 1) return true;
33         p = ans;
34     }
35     if(ans != 1)return true;
36     return false;
37 }
38 bool MR(LL n){
39     if(n <= 1) return false;
40     if(n == 2) return true;
41     if(n % 2 == 0) return false;
42     LL r = n - 1, s = 0;
43     while(r % 2 == 0) r /= 2, s ++;
44     for(int i = 0; i < Safe; i ++)
45         if(check(rand() % (n - 1) + 1, n, r, s)) return false;
46     return true;
47 }
48 inline LL read(){
49     LL x=0;bool sig=1;char ch=getchar();
50     for(;!isdigit(ch);ch=getchar())if(ch=='-')sig=0;
51     for(;isdigit(ch);ch=getchar())x=10*x+ch-'0';
52     return sig?x:-x;
53 }
54 inline void write(LL x){
55     if(x==0){putchar('0');return;}if(x<0)putchar('-'),x=-x;
56     int len=0;static LL buf[20];while(x)buf[len++]=x%10,x/=10;
57     for(int i=len-1;i>=0;i--)putchar(buf[i]+'0');return;
58 }
59 int T;
60 int main(){
61     T=read();LL x;
62     while(T--){
63         x=read();
64         if(x==3){write(2);ENT;continue;}
65         if(x==4){write(2);ENT;continue;}
66         if(MR(x))write(x-1),ENT;
67         else write(0),ENT;
68     }
69 //    for(LL x=1;x<=100;x++){
70 //        LL fac=1;
71 //        for(int i=2;i<x;i++)fac=fac*i%x;write(x);PAU;write(fac);ENT;
72 //    }
73     return 0;
74 }

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

 

1001 Infoplane in Tina Town

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

转载于:https://www.cnblogs.com/chxer/p/4735900.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值