I think: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> struct port { long long x,y,l,r; }; int cmp(const void *a,const void *b) { struct port *x=(struct port *)a; struct port *y=(struct port *)b; retu…
Question 例题3-5 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583) 如果x+x的各个数字之和得到y,就是说x是y的生成元.给出n(1<=n<=100000), 求最小生成元.无解输出0.例如,n=216,121,2005时的解分别是198,0,1979. Think 方法一:假设所求生成元记为m,不难发现m<n.换句话说,只需枚举所有的m<n,看看有木有哪个数是n的生成元.此举效率不高,因为每次计算一个n的生成元…
习题 3-3 分子量 (Molar Mass,ACM/ICPC Seoul 2005,UVa1586) 给出一种物质的分子式(不带括号),求分子量.本题中的分子式只包含4种原子,分别为C,H,O,N,原子量分别为12.01,1.008,16.00,14.01(单位:g/mol).例如,C6H5OH的分子量为94.108g/mol. [我的思路:]首先设想会有哪些情况,然后去分析每种情况怎么解决,比如:问题一:字母+字母 CHO怎么判断,怎么计算?问题二:字母+数字 C,C1,C2这三个会不会都不…
如果x加上x的各个数字之和得到y,就说x是y的生成元.给出n(1≤n≤100000),求最小 生成元.无解输出0.例如,n=216,121,2005时的解分别为198,0,1979. [分析] 本题看起来是个数学题,实则不然.假设所求生成元为m.不难发现m<n.换句话说,只需枚举所有的m<nn,看看有没有哪个数是n的生成元. 可惜这样做的效率并不高,因为每次计算一个n的生成元都需要枚举n-1个数.有没有更快的方法?聪明的读者也许已经想到了:只需一次性枚举100000内的所有正整数m,标记“m加…
#include<stdio.h> int main(void) { char b; int t,cou,sum; scanf("%d",&t); getchar(); while(t--) { cou=sum=0; while((b=getchar())!='\n') { if(b=='O')sum+=++cou; else cou=0; } printf("%d\n",sum); } return 0; }…
生成元:如果 x 加上 x 各个数字之和得到y,则说x是y的生成元. n(1<=n<=100000),求最小生成元,无解输出0. 例如:n=216 , 解是:198 198+1+9+8=216 解题思路:打表 循环将从1到10005(大点也可以)进行提前写好. 例如: 1  1+1=2,-->  arr[2]=1 13 13+1+3=17,-->arr[17]=13 34  34+3+4=41, -->arr[41]=34 打完表后,直接将给的数作为下标,输出即可. #inc…
#include<cstdio>#include<cstdlib>#include<cstring>int main(){ char s[80];//输入OOXXOXXOOO,最终得分计算为1+2+0+0+1+0+0+1+2+3=10 int m = 0, sum = 0, i = 0; scanf("%s", s); for (i = 0; i < strlen(s); i++) { if (s[i] == 'X') m = 0; if (s…
#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;int t, n, a, b, ans, l;int main(){ scanf("%d", &t);//这句话是为了确定一个最大的范围,比如说10000 while (t--) { scanf("%d", &n); ans = 0; for (int i = n - 50;…
1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 #include"stdio.h" #include"string.h" #define maxn 80 int main() { int T,i,m,sum,c; char s[maxn]; scanf("%d",&T); while(T--…
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2005    Accepted Submission(s): 563 Problem Description Little Joh…
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛 ×  Problem A A simple problem   (求N % 1 + N % 2 + ....+ N % N, 待补) ?  Problem B Path √  Problem C Range   (单调栈) √  Problem…
祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方,又不是魔方.具体来说,它不是一个3 * 3 * 3的结构,而是4 * 2的结构. 按照该玩具约定的玩法,我们可反复地以如下三种方式对其做变换: A. 交换上下两行.比如,图(a)经此变换后结果如图(b)所示. B. 循环右移(ZC神从小就懂得这是什么意思的).比如,图(b)经此变换后结果如图(c)所…
Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 seconds Memory limit: 512 megabytes Many of you may have been to St. Petersburg, but have you visited Peterhof Palace? It is a collection of splendid pa…
Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 megabytes Petr and Egor are measuring the gravitational acceleration g on their physics lessons using a special device. An electromag…
http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 735    Accepted Submission(s): 305 Problem Description Bob has N balls and A b…
转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC这项赛事是在大三上的算法课上张老师提到的,当时我们学校的组织参加这项活动才刚刚起步,我也没太在意,总觉得那是非常遥远的事,事实上当时我也从未相当如今我们能获得现在的成绩.真正踏入ACM/ICPC这个神奇的世界,不得不提到2004那一年我们学校的参赛队伍xmutank,正是听了pipo师兄的精彩演讲以…
转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写这篇文章了,但是也很不想去写.毕竟是为之奋斗了两年的目标,不是说舍得就舍得的.然而,自己毕竟是到了该退的时候了,与其扭扭捏捏,不如挥一挥衣袖,尚落得一份潇洒.回首这两年来,有很多是需要总结的.在这里不分巨细的记录下来,或许有点像流水账,但是更多的,是一份对过去的难忘. 童年 我的ACM/ICPC的生…
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Alice was felling into a cave. She found a strange door with a number square m…
http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description All you know Goldbach conjecture.That is to say, Every even integer great…
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1610    Accepted Submission(s): 630 Problem Description (From wikipedia) For bina…
http://acm.hdu.edu.cn/showproblem.php?pid=4707 Pet Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description One day, Lin Ji wake up in the morning and found that his pethamster escaped. He searched in th…
http://acm.hdu.edu.cn/showproblem.php?pid=4706 Children's Day Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) Problem Description Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' is c…
hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 802    Accepted Submission(s): 269 Problem Description hannnnah_j is a teacher in WL High school who teaches biolog…
I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 782    Accepted Submission(s): 406 Problem Description I will show you the most popular board game in the Shanghai Ingress Resis…
QSC and Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 859    Accepted Submission(s): 325 Problem Description Every school has some legends, Northeastern University is the same. Enter…
odd-even number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 388    Accepted Submission(s): 212 Problem Description For a number,if the length of continuous odd digits is even and the length…
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 240 Problem Description This is a simple problem. The teacher gives Bob a list of prob…
Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 439    Accepted Submission(s): 157 Problem Description A mysterious country will hold a football world championships---Abnormal Cup…
Problem Description Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. However, there is something about them you may not kn…
原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 试题来源 ACM/ICPC World Finals 2013 C 问题描述 你现在要为智能汽车负责设计一种很高级的集中管理系统.目的是利用全球信息指导早上从郊区赶往市中心的乘客如何在避免交通堵塞的情况下更好地到达城市中心. 不幸的是,乘客们对城市非常了解,而且都相当自私,你不能简单地甩给他们一条比平常走的还要长的路径(否则他们会直接无视你的指…