A Coin

Kim 有一枚硬币。为了验证这枚硬币是不是均匀的,Kim开始重复抛这枚硬币。
现在给出Kim抛硬币的结果,请你告诉Kim抛出正面的次数占总次数的比例。

签到题。。。

#include #include #include using namespace std;
int main(){
int T,n,x,tot;
cin>>T;
while(T--){
scanf("%d",&n);
tot=0;
for(int i=1;i<=n;i++){
scanf("%d",&x);
tot+=x;
}
printf("%.2lf\n",tot*1.0/n);
}
return 0;
} 

B Time

Second / 86400 =>days
days数值比较小,直接while循环即可。
注意补零。

#include #include #include using namespace std;
const int dy[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool isyear(int year){
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else
return 0;
}
int main(){
int T,year,month,day,second;
cin>>T;
while(T--){
scanf("%d-%d-%d %d",&year,&month,&day,&second);
int t = second / 86400 ;
while(t--){
day++;
if(isyear(year)){
if(month==2&&day==30){
month=3;
day=1;
}
else if(month!=2&&day==dy[month]+1){
month=month+1;
day=1;
}
}
else{
if(day==dy[month]+1){
month=month+1;
day=1;
}
}
if(month==13){
year++;
month=1;
}
}
printf("%d-%02d-%02d\n",year,month,day);
}
return 0;
}

C ID

一个数字出现奇数次,其他偶数次,求出现奇数次的数字。
考验异或运算。

#include #include #include using namespace std;
int main(){
int T;
cin>>T;
while(T--){
long long n,x,ans;
scanf("%lld",&n);
scanf("%lld",&x);
ans=x;
for(int i=2;i<=n;i++){
scanf("%lld",&x);
ans^=x;
}
printf("%lld\n",ans);
}
return 0;
}

D Game

有N个游戏,每个消耗Ti取得Vi的价值。
老师会在某个时间点查房,该时间点不能做事。
完全背包。。。然后每段都是。。

#include #include #include #include using namespace std;
int num[1111];
int f[1111];
int cost[1111];
int value[1111];
int main(){
int T,L,times,n;
cin>>T;
while(T--){
scanf("%d%d%d",&L,×,&n);
for(int i=1;i<=times;i++) scanf("%d",num+i);
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++) scanf("%d%d",cost+i,value+i);
for(int i=1;i<=n;i++){
for(int j=0;j<=L;j++)
if(j-cost[i]>=0){
f[j] = max(f[j] , f[j-cost[i]]+value[i]);
}
}
int ans=0;
sort(num+1,num+1+times);
for(int i=1;i<=times;i++){
ans+=f[num[i]-num[i-1]];
}
if(num[times]

E Mod

求bi%a1%a2%a3%…%an

若b>=a,bmoda<=a2

若b>=a,b\mod a
每次找a[i]右边比a[i]小的数,记下。mod运算的性质。
这样复杂度其实很低。
正解是二分。

#include #include #include #include using namespace std;
struct node{
int r,x;
}info[100005];
int main(){
int T,h;
cin>>T;
while(T--){
int n,m;
scanf("%d",&n);
for(int i=1;i<=n;i++)    scanf("%d",&info[i].x);
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++)
if(info[i].x>info[j].x){
info[i].r=j;
break;
}
}
scanf("%d",&m);
for(int i=1;i<=m;i++){
scanf("%d",&h);
for(int j=1;j<=n;j=info[j].r){
if(j==0||info[j].x==0) break;
h%=info[j].x;
}
printf("%d\n",h);
}
}
return 0;
} 

F Number Game

a跟b玩游戏,每个物品对a,b分别有价值。a每次会去对价值最高 且 对b价值较高的(第二关键字)。求b能取到最大价值。
先进行一次多关键字排序。
往后每次,如果可以用当前的bi换下下一个被拿走的bi使和变大,那就交换。否则取最大的。

#include #include #include #include #include #include using namespace std; struct node{ int x,y; }info[1111]; bool cmp2(node a,node b){ if(a.x==b.x) return a.y>b.y; return a.x>b.x; } struct cmp{ bool operator () (const int &a,const int &b){ return a>b; } }; priority_queue ,cmp> Q; int main(){ int n,T; scanf("%d",&T); while(T--){ while(!Q.empty()) Q.pop(); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&info[i].x); for(int i=1;i<=n;i++) scanf("%d",&info[i].y); sort(info+1,info+n+1,cmp2); for(int i=2;i<=n;i++){ if(!(i&1)){ Q.push(info[i].y); } else if(info[i].y>Q.top()){ Q.pop(); Q.push(info[i].y); } } long long ans=0; while(!Q.empty()){ ans+=Q.top(); Q.pop(); } printf("%lld\n",ans); } return 0; } 

H permutation

容斥原理,推出f[i] = i*f[i-1] - (i-3)*f[i-3]

#include #include #include #define LL long long
using namespace std;
LL f[2222222];
const LL base = 1000000007;
int main(){
f[1]=1;f[2]=1;f[3]=3;
for(LL i=4;i<=2000000;i++){
f[i]=(i * (f[i-1]%base) % base - (i-3) * (f[i-3]%base) %base + base )%base;
}
int T,n;
cin>>T;
while(T--){
scanf("%d",&n);
cout<<

I Team

motherfucker模拟题?
题意不清!撤销无效操作算有效。。。
5WA

#include#include#includeusing namespace std;
const int MAXN = 50005;
int info[MAXN][3];
int succeed[MAXN];
int main(){
int i,j,n,T,m;
scanf("%d",&T);
while(T--){
memset(succeed,0,sizeof(succeed));
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++){
scanf("%d%d",&info[i][0],&info[i][1]);
info[i][2]=1;
}
for(i=m;i>=1;i--){
if(info[i][2]==0) continue;
else if(info[i][0]==3) info[info[i][1]][2]=0;
}
for(i=1;i<=m;i++){
if(info[i][2]==0) continue;
else
{
if(info[i][0]==1) succeed[info[i][1]]=1;
else if(info[i][0]==2) succeed[info[i][1]]=0;
}
}
int sum=0;
for(i=1;i<=n;i++)if(succeed[i]==1) sum++;
printf("%d\n",sum);
int flag=0;
for(i=1;i<=n;i++){
if(flag&&succeed[i]==1) printf(" ");
if(succeed[i]==1) printf("%d",i);
flag=1;
}
puts("");
}
}

J Emirp

就是个打表。。。

#include #include
#include using namespace std;
bool isprime(int x){
for(int i=2;i*i<=x;i++)
if(x%i==0) return 0;
return 1;
}
int reserve(int x){
int r=0;
while(x){
r=r*10+x%10;
x/=10;
}
return r;
}
int main(){
freopen("output.txt","w",stdout);
mapmp;
mp.clear();
for(int i=13;i<=1000000;i++){
if(i==reserve(i)) continue;
if(isprime(i)&&isprime(reserve(i))){
mp[i]++;
mp[reserve(i)]++;
}
}
map::iterator its=mp.begin(); int cnt=0; for(;its!=mp.end();its++){ cout< first<<","; cnt++; if(cnt>1000) break; } return 0; } 
#include #include #include using namespace std;
const int ans[]={0,13,17,31,37,71,73,79,97,107,113,149,157,167,179,199,311,337,347,359,389,701,709,733,739,743,751,761,769,907,937,941,953,967,971,983,991,1009,1021,1031,1033,1061,1069,1091,1097,1103,1109,1151,1153,1181,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1279,1283,1301,1321,1381,1399,1409,1429,1439,1453,1471,1487,1499,1511,1523,1559,1583,1597,1601,1619,1657,1669,1723,1733,1741,1753,1789,1811,1831,1847,1867,1879,1901,1913,1933,1949,1979,3011,3019,3023,3049,3067,3083,3089,3109,3121,3163,3169,3191,3203,3221,3251,3257,3271,3299,3301,3319,3343,3347,3359,3371,3373,3389,3391,3407,3433,3463,3467,3469,3511,3527,3541,3571,3583,3613,3643,3697,3719,3733,3767,3803,3821,3851,3853,3889,3911,3917,3929,7027,7043,7057,7121,7177,7187,7193,7207,7219,7229,7253,7297,7321,7349,7433,7457,7459,7481,7507,7523,7529,7547,7561,7577,7589,7603,7643,7649,7673,7681,7687,7699,7717,7757,7817,7841,7867,7879,7901,7927,7949,7951,7963,9001,9011,9013,9029,9041,9103,9127,9133,9161,9173,9209,9221,9227,9241,9257,9293,9341,9349,9403,9421,9437,9439,9467,9479,9491,9497,9521,9533,9547,9551,9601,9613,9643,9661,9679,9721,9749,9769,9781,9787,9791,9803,9833,9857,9871,9883,9923,9931,9941,9967,10007,10009,10039,10061,10067,10069,10079,10091,10151,10159,10177,10247,10253,10273,10321,10333,10343,10391,10429,10453,10457,10459,10487,10499,10613,10639,10651,10711,10739,10781,10853,10859,10867,10889,10891,10909,10939,10987,10993,11003,11057,11071,11083,11149,11159,11161,11197,11243,11257,11329,11353,11423,11447,11489,11497,11551,11579,11587,11593,11621,11657,11677,11699,11701,11717,11719,11731,11777,11779,11783,11789,11833,11839,11897,11903,11909,11923,11927,11933,11939,11953,11959,11969,11971,11981,12071,12073,12107,12109,12113,12119,12149,12227,12241,12253,12269,12289,12301,12323,12373,12437,12491,12547,12553,12577,12611,12619,12641,12659,12689,12697,12713,12743,12757,12763,12799,12809,12829,12841,12893,12907,12919,12983,13009,13043,13147,13151,13159,13163,13259,13267,13291,13297,13337,13441,13457,13469,13477,13499,13513,13523,13553,13591,13597,13619,13693,13697,13709,13711,13751,13757,13759,13781,13789,13829,13841,13873,13903,13933,13963,14029,14057,14071,14081,14087,14107,14143,14153,14177,14207,14221,14251,14293,14303,14323,14327,14387,14423,14431,14447,14449,14479,14519,14549,14551,14557,14563,14591,14593,14621,14629,14633,14657,14713,14717,14821,14831,14843,14879,14891,14897,14923,14929,14939,14947,14957,15013,15053,15091,15101,15131,15139,15149,15227,15241,15263,15289,15299,15307,15349,15377,15383,15461,15493,15497,15511,15527,15541,15601,15643,15649,15661,15667,15679,15683,15731,15733,15737,15791,15803,15907,15919,15937,15973,16001,16007,16063,16073,16103,16111,16127,16193,16217,16223,16249,16267,16427,16433,16451,16453,16481,16493,16547,16567,16573,16603,16651,16691,16699,16729,16747,16763,16829,16879,16883,16937,16943,16979,17011,17021,17033,17041,17047,17117,17203,17207,17209,17383,17393,17417,17443,17467,17477,17491,17519,17573,17579,17599,17627,17669,17681,17683,17713,17737,17747,17749,17827,17839,17863,17903,17909,17911,17923,17939,17959,18013,18041,18077,18089,18133,18169,18191,18199,18253,18269,18307,18329,18353,18379,18413,18427,18439,18461,18539,18593,18637,18671,18691,18701,18719,18731,18743,18749,18757,18773,18787,18803,18859,18899,18911,18913,19001,19013,19037,19051,19163,19181,19219,19231,19237,19249,19301,19333,19403,19421,19423,19471,19477,19489,19531,19541,19543,19553,19577,19661,19681,19687,19697,19751,19759,19763,19793,19801,19813,19841,19913,19973,30011,30029,30059,30139,30161,30197,30223,30259,30271,30319,30323,30341,30367,30467,30491,30517,30529,30539,30557,30593,30643,30649,30661,30757,30809,30851,30853,30859,30881,30911,30931,30949,30971,30983,31033,31051,31063,31069,31081,31091,31121,31139,31183,31193,31223,31259,31267,31277,31307,31327,31393,31481,31531,31543,31601,31627,31643,31649,31721,31723,31741,31771,31799,31859,31873,31891,31907,31957,31963,31981,31991,32009,32077,32099,32143,32173,32189,32203,32213,32233,32257,32261,32299,32303,32321,32341,32353,32369,32377,32411,32441,32467,32479,32491,32497,32531,32537,32563,32579,32633,32647,32687,32693,32713,32749,32783,32869,32887,32911,32933,32939,32941,32971,32983,32999,33013,33029,33049,33071,33181,33199,33223,33287,33301,33317,33329,33391,33461,33589,33617,33623,33641,33751,33767,33809,33811,33857,33863,33911,33923,33931,34031,34123,34129,34141,34147,34159,34211,34267,34273,34301,34367,34469,34471,34513,34549,34583,34589,34591,34603,34613,34651,34673,34687,34721,34757,34781,34807,34841,34847,34897,34919,34961,34963,35027,35051,35069,35083,35099,35117,35129,35141,35149,35159,35201,35221,35227,35257,35267,35281,35311,35317,35323,35327,35363,35381,35401,35419,35437,35447,35461,35521,35531,35537,35569,35591,35729,35801,35803,35911,35969,35983,35993,36013,36037,36061,36097,36107,36109,36131,36187,36191,36209,36217,36251,36269,36277,36353,36373,36467,36473,36479,36523,36541,36599,36607,36721,36739,36761,36791,36809,36833,36871,36877,36913,36931,36943,36973,37021,37061,37123,37199,37201,37243,37307,37309,37321,37363,37379,37409,37463,37489,37507,37547,37549,37561,37571,37589,37619,37643,37781,37813,37831,37847,37889,37897,37951,37963,37991,37997,38011,38039,38053,38113,38119,38219,38239,38287,38327,38329,38351,38371,38377,38393,38449,38459,38543,38557,38629,38639,38651,38671,38707,38711,38723,38737,38861,38867,38903,38917,38921,38923,38953,38977,38993,39047,39113,39119,39157,39161,39217,39241,39313,39359,39371,39383,39397,39419,39439,39451,39461,39503,39511,39541,39581,39623,39631,39709,39749,39791,39799,39821,39827,39829,39839,39869,39877,39887,39901,39929,39953,39983,39989,70001,70009,70061,70079,70121,70141,70163,70241,70249,70271,70289,70313,70327,70351,70373,70381,70439,70457,70489,70529,70573};
int main(){
int T,x;
cin>>T;
while(T--){
scanf("%d",&x);
printf("%d\n",ans[x]);
}
return 0;
}

科林明伦杯哈尔滨理工大学第六届程序设计团队赛相关推荐

  1. 科林明伦杯哈尔滨理工大学第六届程序设计团队赛(12.10)

    "科林明伦杯"哈尔滨理工大学第六届程序设计团队赛 水题已去除.. B题  Time 原题链接:http://acm.hrbust.edu.cn/index.php?m=Proble ...

  2. 科林明伦杯哈尔滨理工大学第六届程序设计团队赛-Team模拟

    题目链接 题意:有三种操作,1,代表加入数字,2,代表拿出数字,3,代表撤销第i个操作 思路:正着模拟会超时,因为有无限的撤销操作需要递归到上方,所以我们先倒着把撤销的操作都标记下,然后正着模拟(不需 ...

  3. 科林明伦杯哈尔滨理工大学第六届程序设计团队赛(流水账)

    记一次有趣的比赛...... 自己去打的,打的不咋好,写篇博客记录下来... 热身赛是去年个人赛的题,就随便写写. 正式赛开始:A题签到题,没什么说的,但是手速慢了点.写完后B是一个小麻烦的模拟,模拟 ...

  4. 科林明伦杯”哈尔滨理工大学第十届程序设计竞赛B(减成1)

    科林明伦杯"哈尔滨理工大学第十届程序设计竞赛 存在n个数,每次操作可以任选一个区间使得区间内的所有数字减一.问最少多少次操作,可以让所有数都变成1. 数据保证一定有解. 输入描述: 输入t, ...

  5. “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛(同步赛) 题解

    "科林明伦杯"哈尔滨理工大学第十届程序设计竞赛(同步赛) 题解 萌新又来写题解啦 原题链接 B 减成一 题意:存在n个数,每次操作可以任选一个区间使得区间内的所有数字减一.问最少多 ...

  6. “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛 E 赛马 python

    "科林明伦杯"哈尔滨理工大学第十届程序设计竞赛 E 赛马 python E 好家伙 田忌赛马真就 匹配就不解释了 思路,主要咱不止一匹马 所以就最好的比 对方比这个数小的即可 所以 ...

  7. “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛(同步赛)---全题目+题解

    文章目录 A.点对最大值 B.减成一 C.面积 D.扔硬币 E.赛马 F.三角形 G.养花 H.直线 I.字典序 J.最大值 A.点对最大值 链接:https://ac.nowcoder.com/ac ...

  8. “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛(同步赛) F

    F 三角形 链接:https://ac.nowcoder.com/acm/contest/5758/F 来源:牛客网 小明有一根长度为a的木棒,现在小明想将木棒分为多段(每段木棒长度必须为整数), 使 ...

  9. 科林明伦杯 哈尔滨理工大学第十届程序设计竞赛 (补)

    B减成一 利用差分数组,把前后差为正的数都加起来,这里a[0]要设置为1. #include <iostream> #define ll long longusing namespace ...

最新文章

  1. Gson.toJson()时内存溢出StackOverflowError
  2. 预处理器Less和Sass
  3. boost::process::env相关的测试程序
  4. java招聘职位描述,附学习笔记+面试整理+进阶书籍
  5. python基础学习1-列表使用
  6. java面试题10 牛客:以下可以正确获取结果集的有
  7. 工厂模式之消除switch/case语句
  8. php intval0.57100,应用NuSoap构建新型的基于PHP的Web服务
  9. YOLO3 动漫人脸识别
  10. vuex使用及自定义Vue指令vue-permission
  11. centos虚拟机下安装nginx
  12. tsinsen A1333
  13. java welcome-file_通过JSF项目中的welcome-file设置默认主页
  14. 百度AI开放平台文字之身份证识别的实现
  15. linux php虚拟主机,linux上php虚拟主机(linux搭建虚拟主机)
  16. widows上安装golang
  17. pytorch 统计模型参数个数
  18. numpy.ndarray类型方法
  19. 判断用户输入的数为正数还是负数
  20. 效果超好的自制美白面膜大汇总 - 生活至上,美容至尚!

热门文章

  1. nginx常用功能一文概览
  2. 游戏、软件运行是缺少“d3dx**.dll组件”问题的解决方法?
  3. java遍历List常用的两种方式
  4. 智慧小区(智慧小区管理系统)
  5. 智慧小区项目遇到的问题汇总解决参考
  6. select()用法
  7. UE4 虚幻引擎,为自定义的植物添加“”风吹“”效果
  8. AQTime新手入门
  9. 京东商城项目实战(3)------京东商城注册页面
  10. 中兴F660光猫设置命名清单