2015 Fall HIT Weekly Training 3

题目难度加了点。但还是针对新手的。

A.Diff

  这题猛一看没想出来。

  其实就是把数据归类就行了。

  让(A[i]-i)相等的数归为一类,他们中任意两个数都满足A[i] = A[i-k]+k

  a[i-flag]表示A[i]-i == i-flag的个数。

  答案就是n - max{a[i]}

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<string.h>
 4 using namespace std;
 5
 6 #define flag 1000000
 7
 8 int a[2000010];
 9 int b[100010];
10
11 int main(void)
12 {
13   int n;
14   int max;
15   scanf("%d", &n);
16   while(n > 0){
17     //printf("****%d\n", n);
18     memset(a, 0, sizeof(a));
19     for(int i = 0; i < n; ++i) scanf("%d", &b[i]);
20     for(int i = 0; i < n; ++i) a[b[i]-i+flag]++;
21     max = 0;
22     for(int i = 0; i < 2000000; ++i)
23       if(a[i] > max)
24     max = a[i];
25     printf("%d\n", n-max);
26     scanf("%d", &n);
27   }
28   return 0;
29 }

B.Dogs

  这就是一道烂大街的逻辑题。答案是K。

1 #include<cstdio>
2
3 int main(void)
4 {
5   int m, n;
6   while(scanf("%d%d", &m, &n) == 2) printf("%d\n", n);
7   return 0;
8 }

C.The Position

  这题一理解错“no more than”的意思了。

  不少于a个人在前面,就限定了只可能在[a+1, n]中

  不多于b个人在后面,就限定了只可能在[n-b, n]中

  取交集,其中的个数就是min{n-a, b+1}

 1 #include<cstdio>
 2
 3 #define min(a,b) (a) > (b) ? (b) : (a)
 4
 5 int main(void)
 6 {
 7   int a, b, c;
 8   while(scanf("%d%d%d", &a, &b, &c) == 3) printf("%d\n", min(a-b,c+1));
 9   return 0;
10 }

D.Restoring Password

  就是考一下字符串的简单处理。

 1 #include<cstdio>
 2 #include<string>
 3 #include<iostream>
 4 using namespace std;
 5
 6 int main(void)
 7 {
 8   string st;
 9   string s;
10   string a[10];
11   while(cin>>st){
12     for(int i = 0; i < 10; ++i) cin>>a[i];
13     for(int i = 0; i < 80; i += 10){
14       s = st;
15       s.erase(i+10, 70-i);
16       if(i > 0) s.erase(0, i);
17       //cout<<s<<endl;
18       for(int j = 0; j < 10; ++j)
19     if(s == a[j]){
20       cout<<j;
21       break;
22     }
23     }
24     cout<<endl;
25   }
26   return 0;
27 }

1.st.erase(x, y)表示的的是从第x个开始删除y个

2.string貌似用cin,cout比较舒服,反正scanf,printf编译器没过去

E.Rotating

  这道题貌似多年之前在COGS上做过。

  就是一道数学题,去模拟就行了。

  不过提交一次就过了我确实是不敢相信。

 1 #include<cstdio>
 2 #include<cmath>
 3
 4 #define PI 3.1415926535898
 5
 6 double dis(int n, int k){
 7   return sqrt(2-2*cos(k*2*PI/n));
 8 }
 9
10 int main(void)
11 {
12   int N;
13   int n, s;
14   double cir;
15   double ans;
16   scanf("%d", &N);
17   for(int z = 0; z < N; ++z){
18     scanf("%d%d", &n, &s);
19     cir = 0;
20     for(int i = 1; i <= n; ++i) cir += dis(n,i)*(2*PI)/n;
21     ans = s / n * cir;
22     for(int i = 1; i <= s % n; ++i) ans += dis(n,i)*(2*PI)/n;
23     printf("%.2f\n", ans);
24   }
25   return 0;
26 }
时间: 2024-11-03 21:00:30

2015 Fall HIT Weekly Training 3的相关文章

Microsoft Build 2015

Microsoft Build 2015 汇总 简要概括(GitHub 完成约 45%): Visual Studio Code Preview Visual Studio 2015 RC Visual Studio 2013 Update 5 Open Sourcing Visual Studio’s GDB/LLDB Debug Engine Entity Framework 7 Beta 4 ASP.NET 4.6 – Web Forms/ MVC 5/ Web API 2 ASP.NET

UESTC_Dividing Numbers CDOJ 1156

Dividing Numbers Time Limit: 9000/3000MS (Java/Others)     Memory Limit: 262144/262144KB (Java/Others) Submit Status Given an integer N (1≤N≤1013) and K (1≤K≤100) co-prime numbers P1,P2,...,Pk, which are less than 1000. Please tell me how many intege

models-caffes-大全

caffe的伯克利主页:http://caffe.berkeleyvision.org/caffe的github主页:https://github.com/BVLC/caffe caffe的models: http://dl.caffe.berkeleyvision.org/ Index of / ../ mit_mini_places/ 01-Mar-2016 12:18 - bvlc_alexnet.caffemodel 22-Aug-2014 04:36 243862414 bvlc_go

C#实现WebService服务 项目完整总结

项目终于上线了,对于程序员的我来说,还着实令人欣喜不已的.先说一下这个项目做了什么.先介绍一下背景 上面这个流程图介绍了当我们需要take training follow-up的时候,我们需要在sharepoint Desinger中设置工作流,来完成这些功能,但是现在遇到一个问题,workflow的触发是由于登录页面的用户log一条item记录的时候触发的,如果我们要实现邮件的定时提醒功能,那么就需要在每天都触发执行一次workflow,但是由谁来触发呢?刚开始网上搜了很多资料,内网 外网资料

UESTC_Just a Maze CDOJ 1162

Just a Maze Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 262144/262144KB (Java/Others) Submit Status Here is a maze with N × M room. You start from the room (SR,SC) and want to go to the room located at (TR,TC). However, there are many tra

阿尔红军我让我特我问题沃特尔行业

http://www.houzz.com/ideabooks/38419124/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419135/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419147/thumbs/2015.01.04 http://www.houzz.com/ideabooks/38419107/thumbs/2015.01.04 http://www.houzz.c

哪敢跟学长这么

不少人面庞上有不由得惊呼出声http://weibo.com/09.16/2015/p/1001603887569338240338http://weibo.com/09.16/2015/p/1001603887569338268443http://weibo.com/09.16/2015/p/1001603887569342462767http://weibo.com/09.16/2015/p/1001603887569342462769http://weibo.com/09.16/2015/

右手缓缓握拢而

火红烈日炸裂的一路冲杀进去吧http://weibo.com/2015/09/16/p/1001603887216807041204http://weibo.com/2015/09/16/p/1001603887216811186273http://weibo.com/2015/09/16/p/1001603887216811186277http://weibo.com/2015/09/16/p/1001603887216811235528http://weibo.com/2015/09/16/

叶轻灵苦笑一声

灵光刚刚收起时灵兵潮流尽数的牧尘准备不错http://weibo.com/2015.09.16/p/1001603887492385369004http://weibo.com/2015.09.16/p/1001603887492389563376http://weibo.com/2015.09.16/p/1001603887492393757752http://weibo.com/2015.09.16/p/1001603887492397975161http://weibo.com/2015.