随笔分类 - 数学——想法题
摘要:题目链接:http://codeforces.com/problemset/problem/402/B/**算法分析: 题意太大意,positive没注意这个问题 考察等差数列,由An=A1+(n-1)*k,k已知,能够求出A1,找出最大的A1的个数就可以了*/#include#define MAXN 1050#define PI acos(-1.0)#define REP(i,n) for(int i=0; i>>">>">n>>k; int a[MAXN]; map G; int ans=0,mx = 0; FOR(i,1,n)
阅读全文
摘要:题目链接:http://codeforces.com/problemset/problem/402/C/**算法分析: 乱搞题,不明白题目想考什么*/#include#define MAXN 1050#define PI acos(-1.0)#define REP(i,n) for(int i=0; i>>">>">T; while(T --) { int G[30][30]; mem(G,0); int n,p; cin>>n>>p; int sum = 2*n+p,k = 1; while(sum) ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091/** 这题的一种思路就是枚举了:基于这样一个事实:求出lcm = lcm(s1,s2), num1 = lcm/s1, num2 = lcm/s2; 则价值与体积比小的那个宝藏个数一定大于lcm/size;这个用反证法就可证明。然后就是只需要枚举N%lcm + lcm这个体积的最有分配。 */#include#include#include#includeusing namespace std;long long N,s1,v1,s2,v2;long long ans;long long .
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4287#include#include#include#includeusing namespace std;const int maxn = 5500;const int maxm = 1e6;int num[maxm];int map[26] = { 2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9 };int a[7] = {1,10,100,1000,10000,100000};int main(){ //freopen("E:
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4278#include#include#include#includeusing namespace std;int map1[11] = {0,1,2,0,3,4,5,6,0,7,8};int map2[11] = {1,8,64,512,4096,32768,262144,2097152,16777216,134217728,1073741824};int main(){ //freopen("E:\\acm\\input.txt","r",stdin);
阅读全文
摘要:就像1、2元人民币可以凑成任意你想要的面值一样。由于一定会有环,只要有C[i] == 1 就可以造成任何数。够坑吧#include #include #include #include #include #include #include using namespace std;const int maxe = 50000;const int maxn = 1e5+5;const int INF = 0x3f3f3f;int main(){ int C[maxn],T[maxn]; int N,Q; while(cin>>N>>Q){ bool flag = ...
阅读全文
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3365#include #include #include #include #include #include #include #define maxn 50500#define maxe 11000#define INF 0x3f3f3fusing namespace std; int a[maxn],b[maxn];int main(){ //freopen("input.txt","r",stdin); int
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357#include #include #include #include #include #include #include #define maxn 250#define maxe 100050#define INF 0x3f3f3fusing namespace std;int N,T;int ans;bool G[maxn][maxn];int l[maxn];int r[maxn];int lhead,ltail,rhead,rtail;int main(){ //freope...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 10005 9 #define L -110 #define R 111 #define fell 1012 #define Turning -1013 #define On 0;14 15 using namespace std;16 struct ants{17 int location;18 int direction;19 int inputorder;20 ...
阅读全文