码迷,mamicode.com
首页 > 其他好文 > 详细

第十六周 12.13-12.19

时间:2015-12-13 20:20:18      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

12.13

补个BC。

 

HDU 5597 GTW likes function

讨厌打表。

技术分享
 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 typedef long long LL;
 5 
 6 LL Phi(LL n)
 7 {
 8      LL res = n, a = n;
 9      for(LL i = 2LL; i * i <= a; i++) if( a % i == 0 )
10      {
11          res = res / i * ( i - 1 );
12          while(a % i == 0) a /= i;
13      }
14      if( a > 1 ) res = res / a * ( a - 1 );
15      return res;
16 }
17 
18 int main(void)
19 {
20     LL n, x;
21     while(~scanf("%I64d %I64d", &n, &x))
22     {
23         printf("%I64d\n", Phi(n + x + 1LL));
24     }
25     return 0;
26 }
Aguin

 

HDU 5598 GTW likes czf

当然是去搜。然而赛时没调好。赛后仍wa。最后偷看别人代码才发现挖点QAQ。

技术分享
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 typedef long long LL;
 6 const LL mod = 1e9 + 7;
 7 LL cnt, l, r, pow[100];
 8 int d[100], sz;
 9 
10 void dfs(int sz, LL a, LL b)
11 {
12     if( a > r || a + pow[sz+1] <= l || b > r || b + pow[sz+1] <= l ) return;
13     if( a >= l && a + pow[sz+1] - 1 <= r && b >= l && b + pow[sz+1] - 1 <= r )
14     {
15         cnt += pow[sz+1];
16         return;
17     }
18     if(d[sz])
19     {
20         dfs(sz-1, a + pow[sz], b);
21         dfs(sz-1, a, b + pow[sz]);
22     }
23     else
24     {
25         dfs(sz-1, a , b);
26         dfs(sz-1, a + pow[sz], b + pow[sz]);
27     }
28     return;
29 }
30 
31 int main(void)
32 {
33     pow[1] = 1LL;
34     for(int i = 2; i <= 63; i++) pow[i] = pow[i-1] * 2LL;
35     int k;
36     scanf("%d", &k);
37     while(k--)
38     {
39         memset(d, 0, sizeof(d));
40         LL G, T, ans;
41         sz = cnt = 0LL;
42         scanf("%I64d %I64d %I64d %I64d", &l, &r, &G, &T);
43         if(G == T) ans = r - l + 1LL;
44         else
45         {
46             int s = 0;
47             ans = 2 * (r - l + 1LL);
48             LL tmp = G ^ T, p = r;
49             while( tmp )
50             {
51                 d[++sz] = tmp % 2LL;
52                 tmp /= 2LL;
53             }
54             while(p) {p /= 2LL; s++;}
55             dfs(max(sz, s), 0LL, 0LL);
56         }
57         printf("%I64d\n", ( ans - cnt ) % mod);
58     }
59     return 0;
60 }
Aguin

 

第十六周 12.13-12.19

标签:

原文地址:http://www.cnblogs.com/Aguin/p/5043353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!