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都没有人过= =

时间: 2024-08-03 15:46:49

BestCoder Round #51 (div.2)的相关文章

BestCoder Round #51 (div.2) A

Zball in Tina Town Accepts: 397 Submissions: 2463 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大111倍.在第二天的时候,它会变大222倍.在第nnn天的

BestCoder Round #51 (div.2) Zball in Tina Town

威尔逊定理:当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p )    这是一个充分必要条件 这道题是用威尔逊定理做,但不知道定理的话,也没关系,可以打个表, 总结:数论一些题就算不知道某个知识点,也要试着打下表,看能不能找到规律 #include<cstdio> int main() { for(int i=1;i<=13;i++) { int sum=1; for(int j=1;j<i;j++) sum*=j; printf("%d\n"

DP BestCoder Round #50 (div.2) 1003 The mook jong

题目传送门 1 /* 2 DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: 3 dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp[i][0] = dp[i-1][1] + dp[i-1][0]; 4 比赛时二维dp写搓了,主要是边界情况的判断出错,比如dp[3][1] = 1,因为第3块放了木桩,其他地方不能再放,dp[3][0]同理 5 解释一下dp[i][1]的三种情况,可能是前面相隔2个放的方案或者是不放的

计算几何(水)BestCoder Round #50 (div.2) 1002 Run

题目传送门 1 /* 2 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 3 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-8 19:54:14 8 * File Name :B.cpp 9 ************

hdu5418 BestCoder Round #52 (div.2) Victor and World ( floyd+状压dp)

Problem Description After trying hard for many years, Victor has finally received a pilot license. To have a celebration, he intends to buy himself an airplane and fly around the world. There are n countries on the earth, which are numbered from 1 to

BestCoder Round #11 (Div. 2) 前三题题解

题目链接: huangjing hdu5054 Alice and Bob 思路: 就是(x,y)在两个參考系中的表示演全然一样.那么仅仅可能在这个矩形的中点.. 题目: Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 216    Accepted Submission(s): 166 Problem De

BestCoder Round #11 (Div. 2) 题解

HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 302    Accepted Submission(s): 229 Problem Description Bob and Alice got separated in the Square, they agreed that if they

HDU 5651 xiaoxin juju needs help(BestCoder Round #77 (div.1)1001)

传送门 xiaoxin juju needs help Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 861    Accepted Submission(s): 243 Problem Description As we all known, xiaoxin is a brilliant coder. He knew **palin

BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the