随笔分类 - ACM-“水”题
摘要:题意:N个回合。每个回合:name score【名为name的这个人得了score分(可负可正)】。问最后谁的累积分数是最高的。设为M。如果有好几个都得了M,找出这几个人中哪个最早回合累积分数超过【大于等于】M。最早回合累积分:每一个回合结束后每个人都有一个当前的累积分数。思路:这题竟被困了挺久,,...
阅读全文
摘要:题意:一块镜子长宽是a*b。现在要调整(切割)成x:y的比例。问调整完的最大面积是多少。思路:先将x,y弄成最简比例,然后放大到不超过min(a,b)即可。代码:ll a,b,x,y;ll gcd(ll a,ll b){ if(b==0) ret a; ret gcd(b,a%b);}i...
阅读全文
摘要:题意:Nick's company employednpeople. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that ...
阅读全文
摘要:题意:判断从[2,N]中是否有超过【包括】K个数满足:等于一加两个相邻的素数。思路:枚举。也可以:筛完素数,枚举素数,直到相邻素数和超过N。统计个数代码:int n,k;int prime[1005];int cn=0;bool isPrime(int x){ if(x==2) ret tru...
阅读全文
摘要:题意:In one one-dimensional world there arenplatforms. Platform with indexk(platforms are numbered from 1) is a segment with coordinates[(k - 1)m, (k - ...
阅读全文
摘要:题意:求AX^2+BX+C=0的根思路:考虑到A,B,C所有可能的情况代码:double a,b,c;int main(){ cin>>a>>b>>c; if(a==0){ if(b==0){ if(c==0){ puts...
阅读全文
摘要:题意:N个数,找出第二大的数。如果没有输出-1。思路:UNIQUE的使用。代码:int a[105];int n;int main(){ cin>>n; rep(i,0,n-1) cin>>a[i]; sort(a,a+n); int t=unique(a,a+n)-a; ...
阅读全文
摘要:题意:Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of di...
阅读全文
摘要:题意:X坐标上有n个数。JOHN想知道有多少对数满足:x[a]-x[b]>T; while(T--){ cin>>n>>k; rep(i,1,n) scanf("%d",&x[i]); sort(x+1,x+1+n); ll ans=0;...
阅读全文
摘要:题意:A sequencea0, a1, ..., at - 1is called increasing ifai - 1 >n>>d; rep(i,1,n) scanf("%I64d",&a[i]); ll ans=0; rep(i,2,n){ if(a[i]>a[...
阅读全文
摘要:题意:有一个排列,但少了两个数。给你少了这两个数的排列。找出是哪两个数。思路:看代码,,,代码:int a[1005];int main(){ int T; cin>>T; while(T--){ int n; cin>>n; mem(a,0);...
阅读全文
摘要:题意:For each three prime numbers p1, p2 and p3, let's define Hamming sequence Hi(p1, p2, p3), i=1, ... as containing in increasing order all the natura...
阅读全文
摘要:题意:一个数的质因子如果只是2,3,5,7中的若干个。则这个数叫做humble number。例如:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ...给n,问第n个humble number是多少。思路...
阅读全文
摘要:题意:N*M的矩阵,每个格中不是0就是1。可以任意交换某两列。最后得到一个新矩阵。问可以得到的最大的子矩形面积是多少(这个子矩形必须全是1)。思路:先统计,a[i][j]记录从第i行第j列格往上连续的0的个数。枚举每一行作为答案子矩阵的底, 然后将这一行的a[i][j]从大到小排序,扫一遍计算。看代...
阅读全文
摘要:题意:现有公园游船租赁处请你编写一个租船管理系统。当游客租船时,管理员输入船号并按下S键,系统开始计时;当游客还船时,管理员输入船号并按下E键,系统结束计时。船号为不超过100的正整数。当管理员将0作为船号输入时,表示一天租船工作结束,系统应输出当天的游客租船次数和平均租船时间。注意:由于线路偶尔会...
阅读全文
摘要:题意:给一个正整数N,找最小的M,使得N可以整除M,且N/M是质数。数据范围:There are multiple test cases (no more than 1,000). Each case contains only one positive integer N.N≤1,000,000,...
阅读全文
摘要:题意:给你N个数,a1,,,,an。代表第i个管子里有ai个珍珠。规定只能往每根管里增加k的倍数个珍珠。如果存在一套操作,操作完毕后可以得到1~N的一个排列,则Jerry赢,否则Tom赢。问谁赢。思路:将a1...an从小到大排序,可知道每根管里的数只能增不能减。将最后的1...N中的每个数一定是由...
阅读全文
摘要:题意:INPUT:The input of the first line is an integer T, which is the number of test data (T 46q+3r+4u-5v-22w-8x-32y+24z+272 31 -5 0 0 12 0 0 -49 12---> ...
阅读全文
摘要:题意:Input The first line contains an integer T, which indicates the number of test cases. For each test case, there is one line contains a string in...
阅读全文
摘要:题意:给一个n行n列的矩阵M。这个矩阵M由2n-1数构成。分别是t1,t2,....t(2n-1)。m个query。每个query形式:ri, ci。第i个query的答案 ans[i]=E[(ri+ans[i-1])%n][(ci+ans[i-1])%n] E=M*M求m个query的答案和。即a...
阅读全文
浙公网安备 33010602011771号