ACM_HDU
文章平均质量分 92
ITAK
这个作者很懒,什么都没留下…
展开
-
hdu 2138 How many prime numbers
http://acm.hdu.edu.cn/showproblem.php?pid=2138#include <iostream>#include <cstdio>#include <cmath>using namespace std;bool isprime(int m){ if(m == 1) return 0; int n=sqrt((double)m原创 2015-06-16 21:22:09 · 428 阅读 · 0 评论 -
hdu 2203 亲和串
http://acm.hdu.edu.cn/showproblem.php?pid=2203 就是用两个函数就搞定了:#include <iostream>#include <cstring>#include <cstdio>using namespace std;char st[100005];char st1[100005];char st2[200005];int main()原创 2015-06-17 14:55:16 · 546 阅读 · 0 评论 -
hdu 2031(进制转换升级版)
1.这里有零的时候 2.考虑负数 3.就是考虑大于10的情况#include <iostream>#include <cstdio>using namespace std;int a[100005];int n,m;int main(){ while(~scanf("%d %d",&n,&m)) { if(n==0) cout<<原创 2015-05-28 19:58:43 · 961 阅读 · 0 评论 -
hdu 2076 夹角有多大
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int t,h,m,s; cin>>t; while(t--) { cin>>h>>m>>s; if(h>12) //注意还有h>24的时候原创 2015-05-28 18:54:21 · 651 阅读 · 0 评论 -
hdu 2109 (Fighting for HDU)
http://acm.hdu.edu.cn/showproblem.php?pid=2109 水题#include <iostream>#include <algorithm>#include <cstdio>using namespace std;int data1[105];int data2[105];int main(){ int m; while(cin>>原创 2015-06-16 20:11:32 · 1096 阅读 · 0 评论 -
hdu 2212
http://acm.hdu.edu.cn/showproblem.php?pid=2212 唉,只需要打出数来就行了!!!#include <iostream>#include <cstdio>using namespace std;//int jc(int m)//{// int sum=1;// for(int i=1; i<=m; i++)// sum*=i原创 2015-06-17 15:14:30 · 477 阅读 · 0 评论 -
hdu 3783 ZOJ
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3783 比较水#include <iostream>#include <cstring>using namespace std;char str[105];int main(){ while(cin>>str) { if(str[0]=='E')原创 2015-06-17 22:25:43 · 698 阅读 · 0 评论 -
hdu 2669 Romantic
http://acm.hdu.edu.cn/showproblem.php?pid=2669 这就是简单的扩展欧几里得算法,求x 的最小正整数解#include <iostream>#include <cstdio>using namespace std;typedef long long LL;void exgcd(LL a, LL b, LL &x, LL &y){ if(b原创 2015-05-31 11:20:55 · 489 阅读 · 0 评论 -
hdu 1874
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1877#include <iostream>#include <cstdio>using namespace std;int a[100005];int main(){ int a1,b,m,n; while(~scanf("%d",&m),m) { sc原创 2015-06-18 22:07:17 · 495 阅读 · 0 评论 -
hdu 1576 (A/B)
这个题的关键是求逆元,根据扩展欧几里德算法: 代码如下:#include <iostream>#include <cstdio>using namespace std;typedef long long LL;const int mod=9973;void exgcd(LL a,LL b,LL &x,LL &y){ if(b==0) { x=1;原创 2015-05-30 16:50:56 · 763 阅读 · 0 评论 -
hdu 1406
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1406 这题简单,就是有点坑,要考虑m>n的时候#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int main(){ int t; scanf("%d",&t); w原创 2015-06-18 22:40:54 · 736 阅读 · 0 评论 -
hdu 2084 数塔
http://acm.hdu.edu.cn/showproblem.php?pid=2084 每个数的dp值 7 10 15 18 16 15 20 25 20 19 24 30 27 26 24 这是经典的dp#include <iostream>#include <cstdio>#include <cstring>using namespace std;int data[1原创 2015-05-31 21:47:50 · 536 阅读 · 0 评论 -
hdu 1157
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1157 hint:排序#include <iostream>#include <algorithm>using namespace std;int data[10005];int main(){ int m; while(cin>>m) { for(in原创 2015-06-21 22:33:35 · 626 阅读 · 0 评论 -
hdu 2092 整数解
http://acm.hdu.edu.cn/showproblem.php?pid=2092 千万不要用二重循环啊,记住了哦#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ int m,n; while( cin >> m >> n) {原创 2015-05-31 20:32:40 · 565 阅读 · 0 评论 -
hdu 1037
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1037 hint : 只要看懂英语的意思就好了#include <iostream>using namespace std;int main(){ bool flag=0; int data[3]; while(cin>>data[0]>>data[1]>>data[2])原创 2015-06-21 22:14:04 · 641 阅读 · 0 评论 -
hdu 1163
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163 hint:九余数定理一个数对九取余后的结果称为九余数。一个数的各位数字之和想加后得到的<10的数字称为这个数的九余数(如果相加结果大于9,则继续各位相加)#include <iostream>#include <cstdio>using namespace std;int main(){原创 2015-06-21 22:51:20 · 592 阅读 · 0 评论 -
hdu 5272
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5272 这道题就是按照题意模拟。 正常做就行#include <iostream>using namespace std;int main(){ int t; long long m; cin>>t; while(t--) { cin>>m;原创 2015-06-21 10:34:31 · 726 阅读 · 0 评论 -
hdu 1201
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1201 hint:关键是判断是不是闰年的2月29日!!!#include <iostream>#include <cstdio>using namespace std;bool run(int year){ if(year % 400 ==0 ||(year % 4 ==0 && yea原创 2015-06-19 22:53:20 · 682 阅读 · 0 评论 -
hdu 2200
点击打开链接hint:这是一个数学问题,再次只提供公式C(m,n)*(m-1)f(n)=C(2,n)+C(3,n)*2+……+C(k,n)*(k-1)+……C(n,n)*(n-1);#include using namespace std;int main(){ long long m; while(cin>>m) { long原创 2015-06-23 21:57:48 · 635 阅读 · 0 评论 -
hdu 1754 I Hate It
这是个简单题,基本上都是模板类型的:#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=50005;int num[maxn];struct{ int l,r,sum;}tree[4*maxn];int max(int m, int n){原创 2015-06-03 14:08:44 · 409 阅读 · 0 评论 -
hdu 1527
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1527 hint:威佐夫博弈#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;const double k=(sqrt(5.0)-1.0)/2.0;int m原创 2015-06-18 22:27:17 · 669 阅读 · 0 评论 -
hdu 2054 A == B?
http://acm.hdu.edu.cn/showproblem.php?pid=2054 此题巨坑,刚开始我以为是简单的水题,就用strcmp过, but错了,后来经过我苦思冥想,结果还有几组数据 0.0 和 0,1.000和1.0 , 但是我不太确定前面的0是不是有作用我还是写了,但是有人过的时候,前面的0没考虑比如: 002和2可能是相等的,也可能是不想等的所以不用判断,只能说明hd原创 2015-06-04 21:37:06 · 494 阅读 · 0 评论 -
hdu 1849 (尼姆博弈)
http://acm.hdu.edu.cn/showproblem.php?pid=1849 简单的尼姆博弈: 代码如下:#include <iostream>#include <cstdio>using namespace std;int main(){ int m,n,t; while(cin>>m,m) { int ans=0;原创 2015-06-06 11:10:45 · 970 阅读 · 0 评论 -
hdu 1847 Good Luck in CET-4 Everybody!
http://acm.hdu.edu.cn/showproblem.php?pid=1847 简单的巴什博弈,关键是找剩下3的时候,Kiki必输 代码如下:#include <iostream>#include <cstdio>using namespace std;int main(){ int m; while(cin>>m) { if(m%3=原创 2015-06-06 13:08:38 · 587 阅读 · 0 评论 -
hdu 2147 kiki's game
http://acm.hdu.edu.cn/showproblem.php?pid=2147 这是一个巴什博弈的题; 代码如下:#include <iostream>#include <cstdio>using namespace std;int main(){ int m,n; while(cin>>m>>n,m,n) { if(m%2 && n原创 2015-06-06 21:31:51 · 409 阅读 · 0 评论 -
hdu 2108 Shape of HDU
提示叉积: 代码如下:#include <iostream>#include <cstdio>#include <cmath>using namespace std;struct point{ int x; int y;}a[50];int fun(int i,int j,int k) //叉积{ return (a[j].x-a[i].x)*(a[k].y-a原创 2015-06-07 15:29:06 · 432 阅读 · 0 评论 -
hdu 2201 熊猫阿波的故事
http://acm.hdu.edu.cn/showproblem.php?pid=2201 刚开始可能没看懂什么意思,仔细想想就知道了 代码:#include <iostream>#include <cstdio>using namespace std;int main(){ int m,n; while(cin>>m>>n) { printf("原创 2015-06-08 10:56:34 · 638 阅读 · 0 评论 -
hdu 2502
http://acm.hdu.edu.cn/showproblem.php?pid=2502 当n=4时; 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 注意1的个数就是前面的1加上后面的1 所以公式: ans=2^(n-2)*(n-1) + 2^(n-1);#i原创 2015-06-08 12:15:54 · 426 阅读 · 0 评论 -
hdu 2115 I Love This Game
http://acm.hdu.edu.cn/showproblem.php?pid=2115 注意两点: 1:输出格式; 2:结构体排序#include <iostream>#include <algorithm>#include <cstring>using namespace std;struct sa{ char name[55]; int a; int原创 2015-06-08 19:21:08 · 597 阅读 · 0 评论 -
hdu 5265 pog loves szh II
http://acm.hdu.edu.cn/showproblem.php?pid=5265#include <iostream>#include <algorithm>#include <cstdio>using namespace std;const int maxn=100000+5;int data[maxn];int main(){ int m,p; whil原创 2015-06-07 23:05:17 · 800 阅读 · 0 评论 -
hdu 2036
#include <iostream>#include <cstdio>using namespace std;struct line{ int x,y;}data[105];double Area(line p,line q)//面积{ return p.x*q.y-p.y*q.x;}int main(){ int m; while(cin>>m原创 2015-06-09 22:31:43 · 492 阅读 · 0 评论 -
hdu 1848 Fibonacci again and again
这是尼姆博弈的变型; 还是博弈,但是这次要用Sg函数最后异或等于0后手赢 反之,先手赢#include <iostream>#include <cstring>#include <cstdio>using namespace std;int f[100]={1,2,3,5};int e[1005]={0,1,2,3};int b[16];void Init(){ for(原创 2015-06-11 22:24:41 · 675 阅读 · 0 评论 -
hdu 2176 取石子游戏
http://acm.hdu.edu.cn/showproblem.php?pid=2176 提示:尼姆博弈,异或#include <iostream>#include <cstdio>using namespace std;int data[200005];int main(){ int m,s; while(cin>>m,m) { int an原创 2015-06-12 14:50:21 · 749 阅读 · 0 评论 -
hdu 5280 Senior's Array
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5280 问题描述 某天学姐姐得到了一个数组A ,在这个数组的所有非空区间中,她找出了一个区间和最大的,并把这个区间和定义为这个数组的美丽值。但是她觉得这个数组不够美,于是决定修理一下这个数组。学姐姐将会进行一次操作,把原数组中的某个数修改为P (必须修改)。最后她想使得修改后的数组尽可能美丽。请你帮助原创 2015-07-11 23:20:21 · 600 阅读 · 0 评论 -
hdu 5281 Senior's Gun
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5281题目大意:学姐姐是一个酷酷的枪手。她常常会随身携带n 把枪,每把枪有一个攻击力a[i] 。有一天她遇到了m 只怪兽,每只怪兽有一个防御力b[j] 。现在她决定用手中的枪消灭这些怪兽。学姐姐可以用第i 把枪消灭第j 只怪兽当且仅当b[j]≤a[i] ,同时她会获得a[i]−b[j] 的分数。每把枪至多原创 2015-07-11 22:32:47 · 896 阅读 · 0 评论 -
Hdu 5268 (BestCoder Round #44 A)
http://acm.hdu.edu.cn/showproblem.php?pid=5268 简单水题: 只给出代码:#include <iostream>#include <algorithm>using namespace std;int main(){ int T,a,b; cin>>T; for(int k=1; k<=T; k++) {原创 2015-06-14 14:55:40 · 526 阅读 · 0 评论 -
hdu 2504 又见gcd
http://acm.hdu.edu.cn/showproblem.php?pid=2504 hint: 暴力#include <iostream>using namespace std;int gcd(int m, int n){ if(n==0) return m; return gcd(n, m%n);}int main(){ int a,b,t;原创 2015-06-14 21:01:12 · 531 阅读 · 0 评论 -
hdu 2563 统计问题
http://acm.hdu.edu.cn/showproblem.php?pid=2563 递推#include <iostream>using namespace std;int data[25];int main(){ data[1]=3,data[2]=7; for(int i=3; i<21; i++)//递推公式 data[i]=2*data[i-原创 2015-06-14 21:16:13 · 364 阅读 · 0 评论 -
hdu 1999 不可摸数
http://acm.hdu.edu.cn/showproblem.php?pid=1999#include <iostream>#include <cstring>#include <cstdio>using namespace std;int sum[1000001],sign[1001] ;int main(){ for(int i=1; i<=500000; i++)原创 2015-06-15 21:08:21 · 640 阅读 · 0 评论 -
hdu 5310 Souvenir
http://acm.hdu.edu.cn/showproblem.php?pid=5310 题意:今天是BestCoder一周年纪念日. 比赛管理员Soda想要给每个参赛者准备一个纪念品. 商店里纪念品的单价是p 元, 同时也可以花q 元购买纪念品套装, 一个套装里有m 个纪念品.今天总共有n 个参赛者, Soda想要知道最少需要花多少钱才可以给每个人都准备一个纪念品. 输入描述 输入有多组原创 2015-07-26 11:12:51 · 648 阅读 · 0 评论