08 2012 档案

摘要:计算球体积时间限制:3000ms | 内存限制:65535KB难度:1描述根据输入的半径值,计算球的体积。输入输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。(0<R<100)输出输出对应的球的体积,对于每组输入数据,输出一行,计算结果四舍五入为整数Hint:PI=3.1415926样例输入11.5样例输出414View Code #include <iostream>#include <cmath>#define PI 3.1415926using namespace std;int main(){ double r; long int v; 阅读全文
posted @ 2012-08-15 20:26 luosw 阅读(132) 评论(0) 推荐(0)
摘要:三角形面积时间限制:3000ms | 内存限制:65535KB难度:2描述给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积输入每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示三个点的横纵坐标。(坐标值都在0到10000之间)输入0 0 0 0 0 0表示输入结束测试数据不超过10000组输出输出这三个点所代表的三角形的面积,结果精确到小数点后1位(即使是整数也要输出一位小数位)样例输入0 0 1 1 1 30 1 1 0 0 00 0 0 0 0 0样例输出1.00.5View Code #include <stdio.h>#includ 阅读全文
posted @ 2012-08-15 20:12 luosw 阅读(157) 评论(0) 推荐(0)
摘要:不再爱你……时间限制:1000ms | 内存限制:65535KB难度:3描述现在有一个圆柱形水杯,里面装满了水,在它的底部有一个小洞,通过一些简单的物理知识我们可以知道:1、由于重力的原因,水一定会从小洞流出来。2、小洞漏水的速度是和小洞那个位置的水所受到的压力大小成正比的。进而,我们可以知道,漏水的速度V和水面的的高度h成正比,简单起见,我们就直接让v=h吧(只是数值上的相等,v我们认为是单位时间漏出的水的体积,与小孔的大小无关,物理好的童鞋就不要深究了^_^)。3、如果你非常喜欢一个人,理论上在水漏完之前你一定不再喜欢TA了。好吧,扯远了,我们现在的问题是,如果原来倒入了高度为h的水,从水 阅读全文
posted @ 2012-08-15 15:33 luosw 阅读(139) 评论(0) 推荐(0)
摘要:Biorhythms时间限制:1000ms | 内存限制:65535KB难度:3描述Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respectively. There is 阅读全文
posted @ 2012-08-14 12:09 luosw 阅读(145) 评论(0) 推荐(0)
摘要:求余数时间限制:1000ms | 内存限制:65535KB难度:3描述现在给你一个自然数n,它的位数小于等于一百万,现在你要做的就是求出这个数除10003之后的余数输入第一行有一个整数m(1<=m<=8),表示有m组测试数据;随后m行每行有一个自然数n。输出输出n整除10003之后的余数,每次输出占一行。样例输入345465456541样例输出456948View Code #include <iostream>#include <cstring>#include <cstdio>using namespace std;char s[100000 阅读全文
posted @ 2012-08-14 09:48 luosw 阅读(125) 评论(0) 推荐(0)
摘要:快速查找素数时间限制:1000ms | 内存限制:65535KB难度:3描述现在给你一个正整数N,要你快速的找出在2.....N这些数里面所有的素数。输入给出一个正整数数N(N<=2000000)但N为0时结束程序。测试数据不超过100组输出将2~N范围内所有的素数输出。两个数之间用空格隔开样例输入510110样例输出2 3 52 3 5 72 3 5 7 11View Code #include <stdio.h>#include <string.h>#define MAXN 2000001int vis[MAXN];int p[200000]; //存放素数v 阅读全文
posted @ 2012-08-13 19:58 luosw 阅读(205) 评论(0) 推荐(0)
摘要:例题: 幂取模 输入正整数a、n和m ,输出a^n mod m 的值。a,n,m<=10^9.第一种方法:(很容易想出)View Code #include <iostream>using namespace std;int pow_mod(int a,int n,int m){ int ans=1; for(int i=0; i<n; i++) ans=(int)((long long)ans*a % m); return ans;}int main(){ int a,n,m; cin>>a>>n>>m; cout<<p 阅读全文
posted @ 2012-08-13 15:49 luosw 阅读(162) 评论(0) 推荐(0)
摘要:次方求模时间限制:1000 ms | 内存限制:65535 KB难度:3描述 求a的b次方对c取余的值 输入 第一行输入一个整数n表示测试数据的组数(n<100) 每组测试只有一行,其中有三个正整数a,b,c(1=<a,b,c<=1000000000) 输出 输出a的b次方对c取余之后的结果样例输入32 3 53 100 1011 12345 12345样例输出3110481View Code #include <iostream>using namespace std;long long f(long long a,long long b,long long c 阅读全文
posted @ 2012-08-13 14:54 luosw 阅读(148) 评论(0) 推荐(0)
摘要:例题: 大整数取模 输入正整数n和m,输出n mod m的值。n<=10^100,m<=10^9.分析: 首先,把大整数写成“自左向右”的形式:1234=((1*10+2)*10+3)*10+4,然后用前面的公式,每步取模。View Code #include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ char n[200]; int m; scanf("%s %d",n,&m); int len=strle 阅读全文
posted @ 2012-08-13 14:50 luosw 阅读(526) 评论(0) 推荐(0)