Shirlies
宁静专注认真的程序媛~
posts - 222,comments - 49,views - 71万
01 2012 档案
hdu acm1071
摘要:数学题,求积分……#include "stdio.h"#include "math.h"int main(){int cn;scanf("%d",&cn);while(cn--){double x0,y0;double x1,y1,x2,y2;double a,b,c;scanf("%lf%lf",&x0,&y0);scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);a=(y1-y0)/((x1-x0)*(x1-x0 阅读全文
posted @ 2012-01-19 22:07 Shirlies 阅读(204) 评论(0) 推荐(0) 编辑
UVa 10161
摘要:我是用笨方法做的,首先找出该值的范围,然后分奇数偶数讨论。#include "stdio.h"#include "math.h"int main(){int n;int temp;while(scanf("%d",&n)==1&&n){temp=(int)pow(n,0.5);if(temp*temp==n){if(temp%2==0)printf("%d 1\n",temp);elseprintf("1 %d\n",temp);continue;}if(temp%2== 阅读全文
posted @ 2012-01-18 21:20 Shirlies 阅读(170) 评论(0) 推荐(0) 编辑
UVa 113
摘要:用double就可以了Double(双精度浮点型)变量存储为 IEEE 64 位(8 个字节)浮点数值的形式,它的范围在负数的时候是从 -1.79769313486232E308 到 -4.94065645841247E-324,而正数的时候是从 4.94065645841247E-324 到 1.79769313486232E308(来自百度)#include "stdio.h"#include "math.h"int main(){double n,p;double temp;while(scanf("%lf%lf",&n 阅读全文
posted @ 2012-01-18 20:41 Shirlies 阅读(248) 评论(0) 推荐(0) 编辑
hdu acm1286
摘要:欧拉函数φ(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn),其中p1, p2……pn为x的所有质因数,x是不为0的整数。φ(1)=1(唯一和1互质的数就是1本身)。 (注意:每种质因数只一个。比如12=2*2*3欧拉公式那么φ(12)=12*(1-1/2)*(1-1/3)=4)#include "stdio.h"int prime[10000]={1,2,3};int main(){int t;int n;int count;int i,k=3,j,ok;for(i=4;i<32768;i++){ok=1;for(j=1 阅读全文
posted @ 2012-01-18 17:26 Shirlies 阅读(167) 评论(0) 推荐(0) 编辑
hdu acm 2504
摘要:a/gcd(a,b)与b/gcd(a,b)互素就可以做出来了……#include "stdio.h"int gcd(int a,int b){if(a%b==0)return b;elsereturn gcd(b,a%b);}int main(){int a,b;int t,temp;int i;scanf("%d",&t);while(t--){scanf("%d%d",&a,&b);temp=a/b;for(i=2;i<1000000;i++){if(gcd(i,temp)==1){break;}}p 阅读全文
posted @ 2012-01-18 16:22 Shirlies 阅读(232) 评论(0) 推荐(0) 编辑
hdu acm1713
摘要:思路是:通分后求分子的最小公倍数,在除以通分后的分母(看了别人的思路才知道分数的最小公倍数是这样求的,起初只是知道要求公倍数,但是不知道怎么求,汗,我可怜的数学啊~~~)#include "stdio.h"__int64 gcd(__int64 a,__int64 b){if(a%b==0)return b;elsereturn gcd(b,a%b);}int main(){int T;__int64 t1,q1,t2,q2,ts,kq,t;scanf("%d",&T);while(T--){scanf("%I64d/%I64d %I6 阅读全文
posted @ 2012-01-18 10:07 Shirlies 阅读(371) 评论(0) 推荐(0) 编辑
hdu acm2138
摘要:#include "stdio.h"#include "math.h"int is_prim(int n){int i;for(i=2;i<=sqrt(n);i++)//晕,这里用i*i<=n就超时了,没有头绪,莫名其妙,网上看了别人的代码,就将它改成这样,竟然A了,汗~~~……………………哈,忽然想到是为什么了,理由是:当循环到i=46340时i*i<n;但i=46341时i*i=2147488281,超过了int的最大值,溢出变成负数,仍然满足i*i<n!n不是太大的话,运气好还能碰上101128442溢出后等于2147483 阅读全文
posted @ 2012-01-17 23:12 Shirlies 阅读(325) 评论(0) 推荐(0) 编辑
hdu acm 2187
摘要:#include "iostream"#include "stdlib.h"#include "string.h"typedef struct{int p;int w;}rice;int cmp(const void *a,const void *b){ rice *c=(rice *)a; rice *d=(rice *)b;return c->p-d->p;}int main(){int n,m;int c;rice r[1005];scanf("%d",&c);while(c--){sca 阅读全文
posted @ 2012-01-17 21:47 Shirlies 阅读(234) 评论(0) 推荐(0) 编辑
hdu acm 2673
摘要:Problem DescriptionAcmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first.The problem is :Give you a sequence of distinct integers, choose 阅读全文
posted @ 2012-01-17 21:08 Shirlies 阅读(259) 评论(0) 推荐(0) 编辑
hdu acm 1084
摘要:贪心题Problem Description“Point, point, life of student!”This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.There are 5 problems in this final exam. And I will give you 100 阅读全文
posted @ 2012-01-17 20:41 Shirlies 阅读(830) 评论(0) 推荐(0) 编辑
UVa 401
摘要:A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA"is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.A mirrored string is a string for 阅读全文
posted @ 2012-01-16 23:10 Shirlies 阅读(668) 评论(0) 推荐(0) 编辑
UVa 494
摘要:#include "stdio.h"int main(){int count;char ch;int ok=0;while((ch=getchar())!=EOF){ok=0;count=0;while(ch!='\n'){if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))ok=1;if(ok&&!((ch>='A'&&ch<='Z' 阅读全文
posted @ 2012-01-16 13:08 Shirlies 阅读(179) 评论(0) 推荐(0) 编辑
UVa 10055
摘要:最近做的题目可能都会是西班牙Valladolid大学的UVaOJ上面的题目,因为最近看的是Rujia Liu先生的书,他的书上面的题目练习是这个上面的哈这是我在上面做的第一道题目,但是已经开始出现问题啦#include "stdio.h"int main(){long long n,m,t;while(scanf("%lld%lld",&n,&m)==2){if(n>m){t=n;n=m;m=t;}printf("%lld\n",m-n);}return 0;}就是这样写在Microsoft Visual C++ 阅读全文
posted @ 2012-01-15 20:10 Shirlies 阅读(580) 评论(0) 推荐(0) 编辑
c++中文件应用的一点小变化
摘要:留给自己看看,我的博客,我的成长……#include "fstream"//#define fin cin//#define fout cout using namespace std;//改成标准输入输出时可以注释掉下面两行,将上面注释的两行注释符号侧掉 ifstream fin("data.in");ofstream fout("data.out");int main(){int a,b;while(fin>>a>>b)fout<<a+b<<endl;return 0;}还要注意头文 阅读全文
posted @ 2012-01-04 21:26 Shirlies 阅读(225) 评论(0) 推荐(0) 编辑
关于acm程序用到文件的问题
摘要:留给自己看看的,这个博客就是记录自己的心得与所收获的地方。//#define LOCAL#include "stdio.h"#define INF 1000000000int main(){ //以下是重定向版,用来比较方便//如果用红色部分,所有蓝色部分就不要用了//#ifdef LOCAL//freopen("1.in","r",stdin);// freopen("1.out","w",stdout);//#endif//以下是fopen版,有点麻烦,如果要改成读写标准输入输出,要将fin 阅读全文
posted @ 2012-01-04 20:32 Shirlies 阅读(580) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示