这次比赛原本就是来打酱油的,想做个签到题就走!一开始不知道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--------------------------------------------------------------------------------------------------------------------------
江理著名理论AC选手橙子最近在追一个汉子(23333不要问我为什么是汉子),他为了讨取汉子的开心,他准备了若干个三种颜色的橙子,分别为红色,绿色,青色,现在他打算把橙子放到桌子上,摆放的规则是这样的,每个桌子必须放满3个橙子,且每个桌子上橙子颜色的数量要求大于等于两种,现在给出你各个橙子的数量,想问下聪明的你,这么多橙子能放多少张桌子。(注意,一个桌子必须放满橙子才算数)
输入a,b,c分别表示红橙子,绿橙子,青橙子的数量。(0≤a,b,c≤2∗109)(多组输入)
最多能放几张桌子
5 4 3
1 1 1
2 3 3
4
1
2
对于第一组数据 我们可以划分为
gbb
rgg
brr
rrg
g表示绿苹果,r表示红苹果,b表示青苹果
萌妹纸
思路:三个数,判断最大的那个是不是大于另外两个和的两倍,是输入两个和,否则输出三个数相加除以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("%lld\n",y+z);
39 else printf("%lld\n",t);
40 }
41 else
42 printf("%lld\n",s/3);
43 }
44 return 0;
45 }
1002-------------------------------------------------------------------------------------------------------------
江西理工大学竞赛队有一个LOL打的特别好的学长-李俊贤,他曾经放出大话,他一个人带着4个只会喊666的咸鱼就能打进世界总决赛,单杀faker,现在他正在为着自己的梦想不断奋斗者(解释下,他的梦想当然不是单杀faker,而是找4条咸鱼),现在贤大想了一道问题来考考你们,做出来的就可以成为贤大的咸鱼了2333333.
输入一个整数n,求666的n次方的个位数。(多组输入)
对于每组输入数据,输出结果。
1
6
萌妹纸
思路: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("1\n");
10 else if(n>=1)
11 printf("6\n");
12 }
13 return 0;
14 }
1003--------------------------------------------------------------------------------------------------------------------
一位学妹喜欢萌樱花学长已经好长一段时间了,今天很意外在机房遇见萌樱花学长~ 太过直白反而会吓着学长,学妹心里是这么想的,于是她想了一个游戏。 学长,我们玩一个游戏吧,“游戏?”学长满脸疑问看着她。 哎呀,是这种的,我们现在纸上画一个方框,平均分成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! “那我再想一想”,刚说完,学长就得到了答案,学妹失望的走了。 “奇怪,明明答案是正确的啊,怎么不开心呢?”(真实的故事)
输入n表示划分n个格子
(2<=n<=10^5) (多组输入)
输出最小的k满足每一个格子都踩中 k不等于1
8
3
1->4->7->6->3->2->5->8 全部踩中
樱花落舞
思路:给出两种方案,一是打表模拟!
给出参考的伪代码:
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("%d\n",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--------------------------------------------------------------------------------------------------------------------------------
豆豆最近思考计算机为什么要使用二进制的时候,突然想到为什么不使用三进制呢。三进制明显更适合人类思维。毕竟三进制可以表示事物的三种状态(真,假,未知) 三进制是以3为基数的进制。和二进制一样,三进制的数位,称为三进制位(trit),每个三进制位包含 log23(约1.58个)二进制位的信息量。通常,三进制中使用0、1、2三个数字。 n!末尾有多少个0这样的问题对于豆豆来说是非常简单的。豆豆突然想到那么n!转换成3进制后,末尾有多少个0呢?
一个整数n(1<=n<=10^18) (多组数据)
输出n!转换成3进制后,末尾0的个数
3
1
木木
木木
思路:
我们想一想十进制怎么求末尾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("%lld\n", sum);
19 }
20
21 return 0;
22 }
1005--------------------------------------------------------------------------------------------------------------------------
编故事编的好累,懒得编了,直接说了,给你一个n,然后输入n个数,问你这n个数可不可以通过部分加上一个数或者减去一个数使所有数都相等(这个数是固定的),如果可以输出jxust,不可以则输出ecjtujxnu
输入一个数n(1<=n<=10^5) 然后输入n个数。(多组输入)
输出jxust或ecjtujxnu
5
1 3 3 2 1
5
1 2 3 4 5
2
1 2
jxust
ecjtujxnu
jxust
第一组样例可以通过所有的3都减一,所有的1都加一,使全部都变成2.所以输出jxust
第三组样例可以让1加上1,使所有数都变成2,或者让2减去1,使所有数都变成1,所以输出jxust
萌妹纸
思路:
大概知道了如果数组中只存在两种数字,必定是符合要求的
三种如何判断,最小的数字必须增加一个数,最大的数字必须减少一个数字,他们要和中间数字相同,那么是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("ecjtujxnu\n");
34 else
35 {
36 if(cnt<=3)
37 printf("jxust\n");
38 else if(a[3]-a[2]==a[2]-a[1])
39 printf("jxust\n");
40 else
41 printf("ecjtujxnu\n");
42 }
43 }
44 return 0;
45 }
1006---------------------------------------------------------------------------------------------------------------------------------
一群妖王排成一排站在苦情巨树下,寻找自己的转世恋人。 虽然都是妖王,但按照涂山的规定必须进行标号,标号为1的妖王排在最后面,标号为n的妖王排在最前面。每个妖王只有一个妖力值a[i]表示它们现在的地位。 妖王们是讲究实力的,当然不服比它妖力值低的居然可以排在前面,它们现在想知道在它前面,妖力值比它低,而且离它最远的距离是多少?
输入n表示有n个妖王 第二行输入n个整数,表示每个妖王的妖力值a[i] n≤2∗105 1≤a[i]≤109 (多组输入)
对于每个妖王,妖力值比它低,而且离它最远的距离是多少,如果没有输出-1
6
5 50 45 7 10 1
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
yinghualuowu
思路:寻找右边比其小并且最远的;我们记录从右边往左边的区间最小值,一个单调递减的序列,即使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 %d\n",a[i],j);
27 j = (int)v.size() - j ;
28 //printf("%d %d\n",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 }