江西理工大学南昌校区cool code竞赛

时间:2022-05-07
本文章向大家介绍江西理工大学南昌校区cool code竞赛,主要内容包括三种橙子、会喊666的咸鱼、学妹的告白、豆豆的三进制计算机、袁少的游戏、来相思树下、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

      这次比赛原本就是来打酱油的,想做个签到题就走!一开始不知道1002是签到题,一直死磕1001,WA了四发过了,回头一看Rank,三十名,我靠!看了1001的AC率,在我AC之前只有一个人AC了,当时我AC了1001,感觉松了口气,终于算是签到了,看AC率,1%,吓死宝宝了!我啥时候变得这么屌了,连我们学校的大佬都没AC出来,被我这样一个菜鸡给AC了,顿时感觉信心回来了,然后我的电脑上插了一个气球,莫名其妙,还有气球???回头看1002,我靠,WA了三发,什么情况,10^9,肯定超时,WA了一发,原本想什么快速幂弄出来,我真是傻了眼,又WA了两发,我静下心来想想,人家最快27秒AC,不可能很复杂,结果再读了一遍题目,被坑啦!就总共两种情况,n=0和n!=0的情况,然后AC了!Rank 15~~,然后1005我就不说了,估计是没有想清楚,WA了5发,最后Rank 21结束,没办法咯!好好学吧!为了自己的未来,加油!

1001--------------------------------------------------------------------------------------------------------------------------

三种橙子

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 201   Accepted Submission(s) : 7

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

江理著名理论AC选手橙子最近在追一个汉子(23333不要问我为什么是汉子),他为了讨取汉子的开心,他准备了若干个三种颜色的橙子,分别为红色,绿色,青色,现在他打算把橙子放到桌子上,摆放的规则是这样的,每个桌子必须放满3个橙子,且每个桌子上橙子颜色的数量要求大于等于两种,现在给出你各个橙子的数量,想问下聪明的你,这么多橙子能放多少张桌子。(注意,一个桌子必须放满橙子才算数)

Input

输入a,b,c分别表示红橙子,绿橙子,青橙子的数量。(0≤a,b,c≤2∗109)(多组输入)

Output

最多能放几张桌子

Sample Input

5 4 3
1 1 1
2 3 3

Sample Output

4
1
2

对于第一组数据 我们可以划分为
gbb
rgg
brr
rrg
g表示绿苹果,r表示红苹果,b表示青苹果

Author

萌妹纸

思路:三个数,判断最大的那个是不是大于另外两个和的两倍,是输入两个和,否则输出三个数相加除以3;

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5    long long a,b,c;
 6    while(scanf("%lld%lld%lld",&a,&b,&c)!=EOF)
 7    {
 8        long long s=a+b+c;
 9        long long x,y,z;
10        if(a>=b)
11        {
12            if(a>=c)
13            {
14             x=a;
15             if(b>=c)
16             y=c;
17             else y=b;    
18         }
19            else x=c;
20     }
21     else 
22     {
23         if(a>=c)
24         x=b;
25         else
26         {
27             y=a;
28             if(b>=c)
29             x=b;
30             else x=c;
31         }
32     }
33     z=s-x-y;
34     long long t=s/3;
35        if (y+z<=x&&s>=3)
36        {
37           if(y+z<=t)
38               printf("%lldn",y+z);
39               else printf("%lldn",t);
40     }
41        else
42        printf("%lldn",s/3);
43    }
44     return 0;
45 }

1002-------------------------------------------------------------------------------------------------------------

会喊666的咸鱼

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 277   Accepted Submission(s) : 53

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

江西理工大学竞赛队有一个LOL打的特别好的学长-李俊贤,他曾经放出大话,他一个人带着4个只会喊666的咸鱼就能打进世界总决赛,单杀faker,现在他正在为着自己的梦想不断奋斗者(解释下,他的梦想当然不是单杀faker,而是找4条咸鱼),现在贤大想了一道问题来考考你们,做出来的就可以成为贤大的咸鱼了2333333.

Input

输入一个整数n,求666的n次方的个位数。(多组输入)

Output

对于每组输入数据,输出结果。

Sample Input

1

Sample Output

6

Author

萌妹纸

思路:0的话输出1,别的输出6;

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     while(scanf("%d",&n)!=EOF)
 7     {
 8         if(n==0)
 9         printf("1n");
10         else if(n>=1)
11         printf("6n");
12     }
13     return 0;
14 }

1003--------------------------------------------------------------------------------------------------------------------

学妹的告白

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 69   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

一位学妹喜欢萌樱花学长已经好长一段时间了,今天很意外在机房遇见萌樱花学长~ 太过直白反而会吓着学长,学妹心里是这么想的,于是她想了一个游戏。 学长,我们玩一个游戏吧,“游戏?”学长满脸疑问看着她。 哎呀,是这种的,我们现在纸上画一个方框,平均分成n份,编号为1~n,然后呢,我们从1号开始移动k个数字,如果遇上边界就改变方向,就是下面的样子,比如8个格子,移动两个数字(图片不能正常显示请点击:链接http://pan.baidu.com/s/1eR7AHCQ) 1->3->5->7->7->5->3->1->3....如果这样一直跳,就会出现死循环,不能把每一个格子都踩中,那么我们需要最小的k是多少时才能满足每一个格子都踩中呢? “那不是等于1么”学长脱口而出~ 这样就没法玩了,难怪都这么久都没有女朋友,当然k不能等于1! “那我再想一想”,刚说完,学长就得到了答案,学妹失望的走了。 “奇怪,明明答案是正确的啊,怎么不开心呢?”(真实的故事)

Input

输入n表示划分n个格子

(2<=n<=10^5) (多组输入)

Output

输出最小的k满足每一个格子都踩中 k不等于1

Sample Input

8

Sample Output

3

1->4->7->6->3->2->5->8 全部踩中

Author

樱花落舞

思路:给出两种方案,一是打表模拟!

给出参考的伪代码:

 1 int flag[N];
 2 int check(int x,int n)
 3 {
 4     for(int i=1;i<=n;i++)
 5         flag[i]=0;
 6     int ans=0;
 7     int st=1;
 8     int dir=1;
 9     while(ans<n-1)
10     {
11         if(dir)
12             st+=x;
13         else
14             st-=x;
15         if(st<=0)
16             st=2-st,dir=1;
17         else if(st>n)
18             st=2*n-st,dir=0;
19         //cout<<x<<" xxx "<<st<<endl;
20         int p=st;
21         if(flag[p])return 0;
22         ans++;
23         flag[p]=1;
24     }
25     return 1;
26 }

下面给出AC代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <string>
 5 #include <cstring>
 6 #include <algorithm>
 7 #include <queue>
 8 #include <map>
 9 #include <set>
10 #include <stack>
11 #include <sstream>
12 #include <vector>
13 #define PI acos(-1.0)
14 #define N 111111
15 #define M 1000000007
16 #define inf 1e9
17 #define eps 1e-8
18 #define dazhi 2147483647
19 using namespace std;
20 typedef long long ll;
21 int main()
22 {
23     int a[10]= {3,5,7,11,13,17,19,23};
24     int n;
25     while(cin>>n)
26     {
27         int l=3;
28         for(int i=0; i<7; i++)
29         {
30             if(n%l==1)
31                 l*=a[i+1];
32             else
33             {
34                 printf("%dn",a[i]);
35                 break;
36             }
37         }
38     }
39 }

方案二,

如果做过HDU1222题估计会好很多,结论就是gcd(2*n-2,k)==1时,所有格子可以踩中

HDU1222是一个圈啦,这里不是,我们要看成一个圈,比如12321,我们取1232为循环,就是2*3-2(2*n-2)

下面给出AC代码:

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 #include <iostream>   // C++头文件,C++完全兼容C
 6 #include <algorithm>  // C++头文件,C++完全兼容C
 7 #include <time.h>
 8 #define fre  freopen("out.txt","w",stdout)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
 9 #define INF 0x3f3f3f3f
10 #define inf 1e60
11 using namespace std;  // C++头文件,C++完全兼容C
12 const int maxn = 200;
13 int a[maxn];
14 int b[3];
15 int ans,n,k;
16  
17 int main()
18 {
19     while(cin>>n)
20     {
21         for(int i=2; i<=2*n; i++)
22         {
23             if(__gcd(2*n-2,i)==1)
24             {
25                 cout<<i<<endl;
26                 break;
27             }
28         }
29     }
30  
31     return 0;
32 }

1004--------------------------------------------------------------------------------------------------------------------------------

豆豆的三进制计算机

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 31   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

豆豆最近思考计算机为什么要使用二进制的时候,突然想到为什么不使用三进制呢。三进制明显更适合人类思维。毕竟三进制可以表示事物的三种状态(真,假,未知) 三进制是以3为基数的进制。和二进制一样,三进制的数位,称为三进制位(trit),每个三进制位包含 log23(约1.58个)二进制位的信息量。通常,三进制中使用0、1、2三个数字。 n!末尾有多少个0这样的问题对于豆豆来说是非常简单的。豆豆突然想到那么n!转换成3进制后,末尾有多少个0呢?

Input

一个整数n(1<=n<=10^18) (多组数据)

Output

输出n!转换成3进制后,末尾0的个数

Sample Input

3

Sample Output

1

Author

木木

Source

木木

思路:

我们想一想十进制怎么求末尾0,嗯嗯,当然是找被10整除的个数喽

这里情况一样的啦,我们就一直除以3,一直除以3,找被3整除的个数

下面给出AC代码:

 1 #include <stdio.h>
 2 #define freout  freopen("out.txt","w",stdout)
 3 #define frein   freopen("in.txt","r",stdin)
 4 int main ()
 5 {
 6  //   frein;
 7   //  freout;
 8     long long n;
 9     while(~scanf("%lld", &n))
10     {
11         long long sum = 0;
12         long long tmp = 3;
13         while (n >= tmp)
14         {
15             sum += (n / tmp);
16             tmp *= 3;
17         }
18         printf("%lldn", sum);
19     }
20  
21     return 0;
22 }

1005--------------------------------------------------------------------------------------------------------------------------

袁少的游戏

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 200   Accepted Submission(s) : 24

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

编故事编的好累,懒得编了,直接说了,给你一个n,然后输入n个数,问你这n个数可不可以通过部分加上一个数或者减去一个数使所有数都相等(这个数是固定的),如果可以输出jxust,不可以则输出ecjtujxnu

Input

输入一个数n(1<=n<=10^5) 然后输入n个数。(多组输入)

Output

输出jxust或ecjtujxnu

Sample Input

5
1 3 3 2 1
5
1 2 3 4 5
2
1 2

Sample Output

jxust
ecjtujxnu
jxust

第一组样例可以通过所有的3都减一,所有的1都加一,使全部都变成2.所以输出jxust
第三组样例可以让1加上1,使所有数都变成2,或者让2减去1,使所有数都变成1,所以输出jxust

Author

萌妹纸

思路:

大概知道了如果数组中只存在两种数字,必定是符合要求的

三种如何判断,最小的数字必须增加一个数,最大的数字必须减少一个数字,他们要和中间数字相同,那么是a[3]-a[2]==a[2]-a[1]的关系

我们需要做的就是去重计算出他的种类,排序判断

下面给出AC代码:

 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cmath>
 5 #include<string>
 6 #include<queue>
 7 #include<algorithm>
 8 #include<stack>
 9 #include<cstring>
10 #include<vector>
11 #include<list>
12 #include<set>
13 #include<map>
14 using namespace std;
15 #define ll long long
16 #define pi (4*atan(1.0))
17 #define eps 1e-14
18 #define bug(x)  cout<<"bug"<<x<<endl;
19 const int N=1e5+10,M=1e6+10,inf=2147483647;
20 const ll INF=1e18+10,mod=2147493647;
21 ll a[N];
22 int main()
23 {
24     int n;
25     while(~scanf("%d",&n))
26     {
27         for(int i=1; i<=n; i++)
28             scanf("%lld",&a[i]);
29         sort(a+1,a+1+n);
30         int cnt=unique(a+1,a+1+n)-a;
31         //cout<<cnt<<endl;
32         if(cnt>4)
33             printf("ecjtujxnun");
34         else
35         {
36             if(cnt<=3)
37                 printf("jxustn");
38             else if(a[3]-a[2]==a[2]-a[1])
39                 printf("jxustn");
40             else
41                 printf("ecjtujxnun");
42         }
43     }
44     return 0;
45 }

1006---------------------------------------------------------------------------------------------------------------------------------

来相思树下

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 32   Accepted Submission(s) : 0

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

一群妖王排成一排站在苦情巨树下,寻找自己的转世恋人。 虽然都是妖王,但按照涂山的规定必须进行标号,标号为1的妖王排在最后面,标号为n的妖王排在最前面。每个妖王只有一个妖力值a[i]表示它们现在的地位。 妖王们是讲究实力的,当然不服比它妖力值低的居然可以排在前面,它们现在想知道在它前面,妖力值比它低,而且离它最远的距离是多少?

Input

输入n表示有n个妖王 第二行输入n个整数,表示每个妖王的妖力值a[i] n≤2∗105 1≤a[i]≤109 (多组输入)

Output

对于每个妖王,妖力值比它低,而且离它最远的距离是多少,如果没有输出-1

Sample Input

6
5 50 45 7 10 1

Sample Output

4 3 2 1 0 -1

对于第一个数:5,比它小的数字是1,1距离它最远,最远距离为4
对于第二个数:50,比它小的数字是45 7 10 1,1距离它最远,距离为3
对于第三个数:45,比它小的数字是7 10 1,1距离它最远,距离为2
对于第四个数:7,比它小的数字是10 1,1距离它最远,距离为1
对于第五个数:10,比它小的数字是1,1距离它最远,距离为0
对于第六个数:已经没有比它小的数字了,距离为-1

Author

yinghualuowu

原题http://qscoj.cn/problem/17/

思路:寻找右边比其小并且最远的;我们记录从右边往左边的区间最小值,一个单调递减的序列,即使r[i]=min(a[j])i<=j<=n; 我们可以二分右边的那个区间,如果右区间的r[i]<当前的数说明可以向右延伸;

下面给出AC代码:

 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cmath>
 5 #include<string>
 6 #include<queue>
 7 #include<algorithm>
 8 #include<stack>
 9 #include<cstring>
10 #include<vector>
11 #include<list>
12 #include<set>
13 #include<map>
14 using namespace std;
15 #define ll long long
16 #define pi (4*atan(1.0))
17 #define eps 1e-14
18 #define bug(x)  cout<<"bug"<<x<<endl;
19 const int N=1e5+10,M=1e6+10,inf=2147483647;
20 const ll INF=1e18+10,mod=2147493647;
21 int a[N];
22 int r[N];
23 int main()
24 {
25     int n;
26     while(~scanf("%d",&n))
27     {
28         for(int i=1;i<=n;i++)
29             scanf("%d",&a[i]);
30         r[n]=a[n];
31         for(int i=n-1;i>=1;i--)
32             r[i]=min(r[i+1],a[i]);
33         for(int i=1;i<=n;i++)
34         {
35             int st=i+1;
36             int en=n,ans=-1;
37             while(st<=en)
38             {
39                 int mid=(st+en)>>1;
40                 if(a[i]>r[mid])
41                 {
42                     st=mid+1;
43                     ans=mid;
44                 }
45                 else
46                     en=mid-1;
47             }
48             if(ans==-1)
49                 printf("-1");
50             else
51                 printf("%d",ans-i-1);
52             printf("%c",((i==n)?'n':' '));
53         }
54     }
55     return 0;
56 }

实在不会还有这种的(利用C++STL)

下面给出AC代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <vector>
 4 #include <algorithm>
 5 #define MAX 200002
 6 using namespace std;
 7  
 8 int a[MAX],ans[MAX];
 9 vector<int> v,num;
10 #define freout  freopen("out.txt","w",stdout)
11 #define frein   freopen("in.txt","r",stdin)
12 int main()
13 {
14      
15     int n;
16     while(~scanf("%d",&n)){
17         for(int i=0;i<n;i++) scanf("%d",&a[i]);
18         v.clear();
19         num.clear();
20         for(int i=n-1;i>=0;i--){
21             if(v.size()==0 || v.back()>=a[i]){
22                 v.push_back(a[i]); num.push_back(i);
23                 ans[i]=-1;
24             }else{
25                 int j = (lower_bound(v.rbegin(),v.rend(),a[i]) - v.rbegin());
26               //  printf("%d %dn",a[i],j);
27                 j = (int)v.size() - j ;
28                 //printf("%d %dn",num[j+1],j);
29                 ans[i] = num[j] - i - 1;
30             }
31         }
32         for(int i=0;i<n;i++){
33             if(i) printf(" ");
34             printf("%d",ans[i]);
35         }
36         printf("n");
37     }
38     return 0;
39 }