2018-3-17-湖南多校第二场

湖南多校第2场

A:太水 队友直接秒了

C: Hedwig‘s Ladder

队友打了个表,然后一眼规律 类似于斐波拉契

  

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <queue>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <set>
 7 #include <iostream>
 8 #include <map>
 9 #include <stack>
10 #include <string>
11 #include <vector>
12 #include <bits/stdc++.h>
13 #define  pi acos(-1.0)
14 #define  eps 1e-9
15 #define  fi first
16 #define  se second
17 #define  rtl   rt<<1
18 #define  rtr   rt<<1|1
19 #define  bug         printf("******\n")
20 #define  mem(a,b)    memset(a,b,sizeof(a))
21 #define  name2str(x) #x
22 #define  fuck(x)     cout<<#x" = "<<x<<endl
23 #define  f(a)        a*a
24 #define  sf(n)       scanf("%d", &n)
25 #define  sff(a,b)    scanf("%d %d", &a, &b)
26 #define  sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
27 #define  sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
28 #define  pf          printf
29 #define  FRE(i,a,b)  for(i = a; i <= b; i++)
30 #define  FREE(i,a,b) for(i = a; i >= b; i--)
31 #define  FRL(i,a,b)  for(i = a; i < b; i++)+
32 #define  FRLL(i,a,b) for(i = a; i > b; i--)
33 #define  FIN         freopen("data.txt","r",stdin)
34 #define  gcd(a,b)    __gcd(a,b)
35 #define  lowbit(x)   x&-x
36 #define rep(i,a,b) for(int i=a;i<b;++i)
37 #define per(i,a,b) for(int i=a-1;i>=b;--i)
38 using namespace std;
39 typedef long long  LL;
40 typedef unsigned long long ULL;
41 const int INF = 0x3f3f3f3f;
42 const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
43 const int maxn = 1e6 + 7;
44 const int mod = 10007;
45 int T,n,a[maxn];
46 int main() {
47     sf(T);
48     a[1]=2,a[2]=3,a[3]=6;
49     for (int i=4 ;i<=1000 ;i++) a[i]=(a[i-1]+a[i-2]+(i%2!=0))%mod;
50     for (int t=1,x ;t<=T ;t++){
51         sff(x,n);
52         printf("%d %d\n",t,a[n]);
53     }
54     return 0 ;
55 }

E: What time is it anyway?

我的两个SB队友小时也用%02d输出,卡了一年,我在看其他的题目,认为他们两个可以很容易写了,后面我看不下去了,发现他们用小时输出用%02d 当时心态就崩了

题意:模拟题 给你n个时间,和n个相差的时间,让你求你这n个表都一一对应的时间只有一个合法解就输出时间 多个就输出数目 没有输出none

  

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <queue>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <set>
 7 #include <iostream>
 8 #include <map>
 9 #include <stack>
10 #include <string>
11 #include <vector>
12 #include <bits/stdc++.h>
13 #define  pi acos(-1.0)
14 #define  eps 1e-9
15 #define  fi first
16 #define  se second
17 #define  rtl   rt<<1
18 #define  rtr   rt<<1|1
19 #define  bug         printf("******\n")
20 #define  mem(a,b)    memset(a,b,sizeof(a))
21 #define  name2str(x) #x
22 #define  fuck(x)     cout<<#x" = "<<x<<endl
23 #define  f(a)        a*a
24 #define  sf(n)       scanf("%d", &n)
25 #define  sff(a,b)    scanf("%d %d", &a, &b)
26 #define  sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
27 #define  sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
28 #define  pf          printf
29 #define  FRE(i,a,b)  for(i = a; i <= b; i++)
30 #define  FREE(i,a,b) for(i = a; i >= b; i--)
31 #define  FRL(i,a,b)  for(i = a; i < b; i++)+
32 #define  FRLL(i,a,b) for(i = a; i > b; i--)
33 #define  FIN         freopen("data.txt","r",stdin)
34 #define  gcd(a,b)    __gcd(a,b)
35 #define  lowbit(x)   x&-x
36 #define rep(i,a,b) for(int i=a;i<b;++i)
37 #define per(i,a,b) for(int i=a-1;i>=b;--i)
38 using namespace std;
39 typedef long long  LL;
40 typedef unsigned long long ULL;
41 const int INF = 0x3f3f3f3f;
42 const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
43 const int maxn = 1e6 + 7;
44 int T, n, num1[12], num2[12], num3[12];
45 map<int, int>vis;
46 set<int>ans;
47 int main() {
48    // FIN;
49     sf ( T );
50     for ( int t = 1, x ; t <= T ; t++ ) {
51         ans.clear();
52         sff ( x, n );
53         for ( int i = 0, a, b ; i < n ; i++ ) {
54             scanf ( "%d:%d", &a, &b );
55             num1[i] = a * 60 + b;
56             if (num1[i]>=720) num1[i]%=720;
57         }
58         getchar();
59         char op;
60         for ( int i = 0, a, b ; i < n ; i++ ) {
61             scanf ( " %c%d:%d", &op, &a, &b );
62             if ( op == ‘+‘ ) num2[i] = a * 60 + b;
63             else num2[i] = - ( a * 60 + b );
64             vis[num2[i]]++;
65         }
66         for ( int i = 0 ; i < n ; i++ ) {
67             num3[i] = num1[0] - num2[i];
68             if ( num3[i] < 0 ) num3[i] += 720;
69             if ( num3[i] >= 720 ) num3[i] %= 720;
70         }
71         for ( int i = 0 ; i < n ; i++ ) {
72             int flag = 1;
73             vis.clear();
74             for ( int j = 0 ; j < n ; j++ ) vis[num1[j]]++;
75             for ( int j = 0 ; j < n ; j++ ) {
76                 int cnt = num3[i] + num2[j];
77                 if ( cnt >= 720 ) cnt %= 720;
78                 if ( cnt < 0 ) cnt += 720;
79                 if ( !vis[cnt] ) {
80                     flag = 0;
81                     break;
82                 }
83                 vis[cnt]--;
84             }
85             if ( flag ) ans.insert( num3[i] );
86         }
87         if ( ans.size() == 0 ) printf ( "%d none\n", t );
88         else if ( ans.size() == 1 ) {
89             int a = *ans.begin() / 60, b = *ans.begin() % 60;
90             if ( a == 0 ) a = 12;
91             printf ( "%d %d:%02d\n", t, a, b );
92         } else printf ( "%d %d\n", t, ans.size() );
93     }
94     return 0 ;
95 }

H: Subprime Fibonacci Sequence

让你求出循环节 这题题目已经告诉你如何求出循环节了 然后被卡了好久  SB了  ak?=?am and ak?−?1?=?am?−?1  

找到两个相同的就行了,应该是这种数列的性质

  

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <queue>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <set>
 7 #include <iostream>
 8 #include <map>
 9 #include <stack>
10 #include <string>
11 #include <vector>
12 #include <bits/stdc++.h>
13 #define  pi acos(-1.0)
14 #define  eps 1e-9
15 #define  fi first
16 #define  se second
17 #define  rtl   rt<<1
18 #define  rtr   rt<<1|1
19 #define  bug         printf("******\n")
20 #define  mem(a,b)    memset(a,b,sizeof(a))
21 #define  name2str(x) #x
22 #define  fuck(x)     cout<<#x" = "<<x<<endl
23 #define  f(a)        a*a
24 #define  sf(n)       scanf("%d", &n)
25 #define  sff(a,b)    scanf("%d %d", &a, &b)
26 #define  sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
27 #define  sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
28 #define  pf          printf
29 #define  FRE(i,a,b)  for(i = a; i <= b; i++)
30 #define  FREE(i,a,b) for(i = a; i >= b; i--)
31 #define  FRL(i,a,b)  for(i = a; i < b; i++)+
32 #define  FRLL(i,a,b) for(i = a; i > b; i--)
33 #define  FIN         freopen("data.txt","r",stdin)
34 #define  gcd(a,b)    __gcd(a,b)
35 #define  lowbit(x)   x&-x
36 #define rep(i,a,b) for(int i=a;i<b;++i)
37 #define per(i,a,b) for(int i=a-1;i>=b;--i)
38 using namespace std;
39 typedef long long  LL;
40 typedef unsigned long long ULL;
41 const int INF = 0x3f3f3f3f;
42 const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
43 const int maxn = 1e6 + 7;
44 int num, vis[maxn], prime[maxn], vis1[maxn];
45 int T, n, a[1010],len, idx;
46 void init() {
47     num = 0, vis1[1] = 1;
48     for ( int i = 2 ; i < maxn ; i++ ) {
49         if ( vis[i] ) continue;
50         for ( int j = 2 * i ; j < maxn ; j += i ) vis[j] = 1;
51         vis1[i] = 1, prime[num++] = i;
52     }
53 }
54 int getnum ( int x ) {
55     if ( vis1[x] ) return x;
56     for ( int i = 0 ; i < num ; i++ )
57         if ( x % prime[i] == 0 ) return x / prime[i];
58 }
59 map<int, int>mp;
60 int main() {
61     //FIN;
62     init();
63     sf ( T );
64     for ( int t = 1, x ; t <= T ; t++ ) {
65         mp.clear();
66         len = 0, idx = 0;
67         mem ( a, 0 );
68         sffff ( x, n, a[0], a[1] );
69         for ( int i = 2 ; i <= n ; i++ ) a[i] = getnum ( a[i - 1] + a[i - 2] );
70       //  for ( int i = 0 ; i <= n ; i++ ) printf ( "%d%c", a[i], i == n ? ‘\n‘ : ‘ ‘ );
71         for ( int i = 0 ; i <= n-1 ; i++ ) {
72             if (mp[a[i]*10000+a[i+1]]) {
73                 idx=i;
74                 len=idx-mp[a[i]*10000+a[i+1]];
75                 break;
76             }
77             mp[a[i]*10000+a[i+1]]=i;
78         }
79         if ( !len )   printf ( "%d %d 0\n%d\n", t, n, a[n] );
80         else {
81             for ( int i = 0, j = 0 ; i <= n ; i++ ) {
82                 if ( a[i] == a[i + len] ) {
83                     if ( j == 0 ) idx = i + len;
84                     j++;
85                     if ( j == 2 ) break;
86                 } else j = 0;
87             }
88             printf ( "%d %d %d\n", t, idx + 1, len );
89             int res = 0;
90             for ( int i = idx - len; i <= idx + 1; i++ ) {
91                 res++;
92                 if ( res == 20 || i == idx + 1 )  printf ( "%d\n", a[i] ), res = 0;
93                 else printf ( "%d ", a[i] );
94             }
95             // if ( res ) printf ( "\n" );
96         }
97     }
98     return 0 ;
99 }

G: The Erdo?s-Straus Conjecture

这题没什么想法,大佬告诉我这题枚举就行了,后面发现开了10S枚举 也不会T

  

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <queue>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <set>
 7 #include <iostream>
 8 #include <map>
 9 #include <stack>
10 #include <string>
11 #include <vector>
12 #include <bits/stdc++.h>
13 #define  pi acos(-1.0)
14 #define  eps 1e-9
15 #define  fi first
16 #define  se second
17 #define  rtl   rt<<1
18 #define  rtr   rt<<1|1
19 #define  bug         printf("******\n")
20 #define  mem(a,b)    memset(a,b,sizeof(a))
21 #define  name2str(x) #x
22 #define  fuck(x)     cout<<#x" = "<<x<<endl
23 #define  f(a)        a*a
24 #define  sf(n)       scanf("%d", &n)
25 #define  sff(a,b)    scanf("%d %d", &a, &b)
26 #define  sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
27 #define  sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
28 #define  pf          printf
29 #define  FRE(i,a,b)  for(i = a; i <= b; i++)
30 #define  FREE(i,a,b) for(i = a; i >= b; i--)
31 #define  FRL(i,a,b)  for(i = a; i < b; i++)+
32 #define  FRLL(i,a,b) for(i = a; i > b; i--)
33 #define  FIN         freopen("data.txt","r",stdin)
34 #define  gcd(a,b)    __gcd(a,b)
35 #define  lowbit(x)   x&-x
36 #define rep(i,a,b) for(int i=a;i<b;++i)
37 #define per(i,a,b) for(int i=a-1;i>=b;--i)
38 using namespace std;
39 typedef long long  LL;
40 typedef unsigned long long ULL;
41 const int INF = 0x3f3f3f3f;
42 const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
43 const int maxn = 1e6 + 7;
44 int T, t;
45 LL n, a, b, c;
46 void solve() {
47     a = n / 4 + 1;
48     while ( 1 ) {
49         LL x = 4 * a - n;
50         LL y = a * n;
51         LL temp = gcd ( x, y );
52         x /= temp, y /= temp;
53         b = y / x + 1;
54         for ( ; b <= 2 * y / x ; b++ ) {
55             LL x1 = x * b - y;
56             LL y1 = y * b;
57             if ( y1 % x1 == 0 ) {
58                 printf ( "%d %lld %lld %lld\n", t, a, b, y1/x1 );
59                 return ;
60             }
61         }
62         a++;
63     }
64 }
65 int main() {
66     sf ( T );
67     for ( t = 1; t <= T ; t++ ) {
68         int x;
69         sff ( x, n );
70         solve();
71     }
72     return 0 ;
73 }

原文地址:https://www.cnblogs.com/qldabiaoge/p/10560377.html

时间: 2024-11-05 22:04:27

2018-3-17-湖南多校第二场的相关文章

多校第二场 简单排序计算

思路:先按交叉相乘之差排序好了计算就行了. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <map> #include <cstdlib> #include <queue> #include <stack> #include <vector> #include <ctype.

2018 hdu 多校 第二场

因为3点半才来(其实是3点50,刚刚到酒店就开始了= =队友也是一个那时刚刚睡醒= = 1004 小甜甜 全部yes就好了 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #include <vector> 6 #include <queue> 7 #include <set> 8 #include

hdu 5305 Friends(2015多校第二场第6题)记忆化搜索

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5305 题意:给你n个人,m条关系,关系可以是online也可以是offline,让你求在保证所有人online关系的朋友和offline关系的朋友相等的情况下,这样的情况有多少种. 思路:因为online关系和offline关系的人数相等,而且m最多才28,所以只要枚举每个人的一半的关系是否符合要求即可,而且根据题意m是奇数或者有一个人的总关系为奇数那么就没有符合要求的情况,这样可以排除很多情况.

hdu_6055 : Regular polygon (2017 多校第二场 1011) 【计算几何】

题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[i]->p[j]) (j>i),只判断这个向量左侧可否存在两个点与它一起构成一个正方形.这样算的结果是,计数每个正方形时,它的靠右和靠下的两条边都会为ans贡献一个单位,所以最后ans要除以2. #include<bits/stdc++.h> using namespace std;

hdu 5308 (2015多校第二场第9题)脑洞模拟题,无语

题目链接:http://acm.hdu.edu.cn/listproblem.php?vol=44 题意:给你n个n,如果能在n-1次运算之后(加减乘除)结果为24的输出n-1次运算的过程,如果不能输出-1. 思路:乍看起来,没什么规律,但是可以想象的是(n+n+n+n)/n=4,(n+n+n+n+n+n)/n=6,(n-n)*n*n*·····*n=0所以在n大于15的时候结果基本是固定的,只要对小于15的数一一输出就行(但是这题真是无语,算这种题目真是累,脑洞啊~~) 代码: 1 #incl

HDU 5308 I Wanna Become A 24-Point Master(2015多校第二场)

I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 485    Accepted Submission(s): 191 Special Judge Problem Description Recently Rikka falls in love with an old bu

HDU6315 Naive Operations(多校第二场1007)(线段树)

Naive Operations Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 3636    Accepted Submission(s): 1612 Problem Description In a galaxy far, far away, there are two integer sequence a and b of l

hdu_6050: Funny Function (2017 多校第二场 1006) 【找规律】

题目链接 暴力打个表找下规律就好了,比赛时看出规律来了倒是,然而看这道题看得太晚了,而且高中的那些数列相关的技巧生疏了好多,然后推公式就比较慢..其实还是自身菜啊.. 公式是 #include<bits/stdc++.h> using namespace std; typedef long long LL; const LL mod=1e9+7; LL qpow(LL x,LL n) //求x^n%mod { LL ret=1; for(; n; n>>=1) { if(n&

2015多校第二场 1004( Delicious Apples )

题意:有一条圆形的路,你的仓库在0点,这条路长l,然后有n个苹果树,每个数的坐标是xi(顺时针),每棵树上有ai个苹果.你有个篮子,能装k个苹果,问你用这个篮子将所有苹果装回仓库所走的最短路为多少? 1≤n,k≤105,ai≥1,a1+a2+...+an≤105 1≤L≤109 0≤x[i]≤L 请特别注意上面的苹果个数的条件.因为我的学长 就是从这个条件成功做出了这道题,orz! 因为苹果数不超过10^5,所以将每个苹果当作点. 用一个数组pos记录每个苹果距0点的距离,排序后,然后就可以用另