zoj 4099 Extended Twin Composite Number】的更多相关文章

Do you know the twin prime conjecture? Two primes  and  are called twin primes if . The twin prime conjecture is an unsolved problem in mathematics, which asks for a proof or a disproof for the statement "there are infinitely many twin primes".…
毒瘤出题人,坑了我们好久,从基本的素数筛选,到埃氏筛法,到随机数快速素数判定,到费马小定理,好好的水题做成了数论题. 结果答案是 2*n=n+3*n,特判1,2. 以下为毒瘤题目: 题目大意: 输入一个数n, 输出两个合数(即非素数)a,b 实现 n+a=b 解题思路 3n=n+2n; 特判1.2 代码: #include<iostream> #include<stdio.h> using namespace std; typedef long long ll; int T; ll…
ZOJ 2971 Give Me the Number 题目 ZOJ 2311 Inglish-Number Translator 题目 //两者题目差不多,细节有点点不一样,因为不是一起做的,所以处理方式有一点点不一样——还是前一个方式高端呀. //ZOJ 2971 的AC代码(用了strstr函数): #include<stdio.h> #include<string.h> ][] = {"zero" , "one" , "tw…
The Twin Towers Time Limit: 2 Seconds      Memory Limit: 65536 KB Twin towers we see you standing tall, though a building's lost our faith will never fall. Twin towers the world hears your call, though you're gone it only strengthens our resolve. We…
Give Me the Number Numbers in English are written down in the following way (only numbers less than 109are considered). Number abc,def,ghi is written as "[abc] million [def] thousand [ghi]". Here "[xyz] " means the written down number …
Give Me the Number Time Limit: 2 Seconds      Memory Limit: 65536 KB Numbers in English are written down in the following way (only numbers less than 109 are considered). Number abc,def,ghi is written as "[abc] million [def] thousand [ghi]". Her…
双塔DP. dp[i][j]表示前i个物品,分成两堆(可以不全用),价值之差为j的时候,较小一堆的价值为dp[i][j]. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ][ + ]; ]; int n, sum; void read() { ; i <= n; i++) scanf("%d",…
题意:给定一个序列,里面有一个数字出现了超过 n / 2,问你是哪个数字,但是内存只有 1 M. 析:首先不能开数组,其实也是可以的了,后台数据没有那么大,每次申请内存就可以过了.正解应该是贪心,模拟一个栈,因为答案肯定出现次数比其他所有数字的出现次数还多,所以每次和栈顶的元素比较,如果相同,就放到栈里,否则删除栈顶元素,这样最后剩下的肯定是出现次数最多的元素,我们可以用两个变量来模拟这个栈. 代码如下: #pragma comment(linker, "/STACK:1024000000,10…
pro:给定N个数的数组a[],其中一个数X的出现次数大于N/2,求X,空间很小. sol:不能用保存数组,考虑其他做法. 由于出现次数较多,我们维护一个栈,栈中的数字相同,所以我们记录栈的元素和个数即可,如果新加入一个数与栈中数不同,则弹出一个元素(tot--),否则加入,最后保留在栈中的就是答案. #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; int D,to…
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A     Thanks, TuSimple! Time Limit: 1 Second      Memory Limit: 65536 KB 题意:有t组数据,n个男生,m个女生,每个人身高不同,每个人都期望和比自己高或者比自己低的人跳舞,问最多有多少对舞伴 题解:把期待比自己高的男生身高和期待比自己低的男生身高分别存在两个数组a[n],b[n]里,同…