- 博客(80)
- 收藏
- 关注
原创 HOJ 1271 Biker's Trip Odometer
http://acm.hit.edu.cn/hoj/problem/view?id=1271#include #include const double pi = acos(-1);int main(){ double d, r, s, distance, speed, count; count = 1; while (scanf("%lf %lf %lf
2012-11-28 17:55:21
243
原创 HOJ 1296 Big Number
http://acm.hit.edu.cn/hoj/problem/view?id=1296计算n!的位数斯特灵公式:n!≈sqrt(2*pi*n)*(n/e)^n#include #include const double e = 2.7182818284590452354, pi = acos(-1);int main(){ int n; int c
2012-11-28 17:55:11
246
原创 HOJ 1302 Sum of Factorials
http://acm.hit.edu.cn/hoj/problem/view?id=1302问一个数能否被阶乘的和表示0!=1The input is terminated by a line with a negative integer.#include int f(int x){ int i, pro = 1; if(x == 0)
2012-11-28 17:55:07
270
原创 HOJ 1331 Deck
http://acm.hit.edu.cn/hoj/problem/view?id=1331#include #include double f(int n);int main(){ int n; printf("# Cards Overhang\n"); while (scanf("%d", &n) != EOF) { prin
2012-11-28 17:54:52
285
原创 HOJ 1365 Digital Product
http://acm.hit.edu.cn/hoj/problem/view?id=1365给一个整数n输出最小的整数k使得k的每一位的乘积等于nn=0和n=1单独处理#include int main(){ int n, i, j, p; int factor[10] = {0}; while (scanf("%d", &n) != EOF)
2012-11-28 17:54:48
300
原创 HOJ 1370 Candy
http://acm.hit.edu.cn/hoj/problem/view?id=1370不能平分就输出-1N很大 数组开大一点#include #include int block[16384];double average(int block[], int size);bool isint(double x);int main(){ int i, n,
2012-11-28 00:06:18
250
原创 HOJ 1439 The Circumference of the Circle
http://acm.hit.edu.cn/hoj/problem/view?id=1439给出三个点坐标 计算过这三个点的圆的周长利用a/sinA=2R和S=0.5*bcsinA计算 S可用叉乘算#include #include const double pi = acos(-1);double find_r(double x1, double y1, double x2,
2012-11-28 00:06:15
382
原创 HOJ 1459 Goldbach's Conjecture
http://acm.hit.edu.cn/hoj/problem/view?id=1459Every even number greater than 4 can be written as the sum of two odd primenumbers.#include#includebool pri(int n);int main(){ int n, i;
2012-11-28 00:06:13
245
原创 HOJ 1446 Binomial Showdown
http://acm.hit.edu.cn/hoj/problem/view?id=1446计算组合数#include double Binomial(int n, int k);int main(){ int n, k; double res; while (scanf("%d %d", &n, &k) != EOF) { if
2012-11-28 00:06:13
268
原创 HOJ 1496 World Cup Noise
http://acm.hit.edu.cn/hoj/problem/view?id=1496计算不含有连续的1的二进制数个数注意格式#include #include int main(){ int a[64]; int n,t,i; for (i = 1; i <= 45; i++) { if (i <= 2)
2012-11-28 00:05:08
191
原创 HOJ 1995 Venn Diagram
http://acm.hit.edu.cn/hoj/problem/view?id=1995把N=4画一下结果就出来了fn=n^2-n+2N=0时有空集 要输出1#include int main(){ int cases, n, fn; scanf("%d", &cases); while (cases--) { scanf
2012-11-27 23:20:06
218
原创 HOJ 2546 The right time
http://acm.hit.edu.cn/hoj/problem/view?id=2546t2和t3是正确时间 t1和t4计算间隔走回家用的时间是去的两倍#include struct time{ int hour; int minute;}t1, t2, t3, t4, arrive;int main(){ int delta, total;
2012-11-27 23:20:03
230
原创 HOJ 2589 Conversions
http://acm.hit.edu.cn/hoj/problem/view?id=2589单位转换#include #include const double kg2lb = 2.2046;const double lb2kg = 0.4536;const double l2g = 0.2642;const double g2l = 3.7854;int main(){
2012-11-27 23:20:00
209
原创 HOJ 2603 Look and Say
http://acm.hit.edu.cn/hoj/problem/view?id=2603#include #include int main(){ int cases, n, len, i; char number[1024]; scanf("%d", &cases); getchar(); while (cases--) {
2012-11-27 23:19:58
216
原创 HOJ 2620 The Dragon of Loowater
http://acm.hit.edu.cn/hoj/problem/view?id=2620给出龙头个数和骑士人数骑士身高大于龙头直径时可以砍下龙头排序完扫一遍#include #include int compar(const void *a, const void *b);int main(){ int n, m; int diameter[2000
2012-11-27 23:19:56
199
原创 HOJ 2695 Humidex
http://acm.hit.edu.cn/hoj/problem/view?id=2695给三个数字中的两个 根据公式计算出第三个#include #include double solve_t(double d, double h);double solve_d(double t, double h);double solve_h(double t, double d);
2012-11-27 23:19:53
218
原创 HOJ 2769 Patterns and Pictures
http://acm.hit.edu.cn/hoj/problem/view?id=2769计算每组占的面积#include #include int main(){ int n, i, s, r, sum; int a, b, c; scanf("%d", &n); while (n--) { sum = 0;
2012-11-27 23:19:50
238
原创 HOJ 2773 Bones
http://acm.hit.edu.cn/hoj/problem/view?id=2773给若干个骨头摆成金字塔形注意格式#include #include int main(){ int i,j,n,k; while (scanf("%d", &n) != EOF) { while (n > 0) {
2012-11-27 23:19:47
258
原创 HOJ 2786 Convert Kilometers to Miles
http://acm.hit.edu.cn/hoj/problem/view?id=2786公里转化为英里公里数用最少个斐波那契数表示即42表示为34+8 而不是34+5+2+1#include void calc_fib(int f[]);int main(){ int i, f[32]; int t, x, y; bool flag[32];
2012-11-27 23:19:44
297
原创 HOJ 1526 Drink, on Ice
http://acm.hit.edu.cn/hoj/problem/view?id=1526分别计算冰和水的E-T函数利用体系总能量判断状态#include #include const double CW = 4.19, CI = 2.09;const double BW = 397.7, BI = 62.7;conse double EM = 335;int main
2012-11-25 00:11:20
259
原创 HOJ 1599 Box of Bricks
http://acm.hit.edu.cn/hoj/problem/view?id=1599计算移动砖块的次数高度大于平均数的减去平均数求和即可注意格式#include int main(){ int n, h[128], i, j, sum, avg, count, k; count = 0; while (scanf("%d", &n)
2012-11-25 00:11:18
353
原创 HOJ 1610 Twenty Questions
http://acm.hit.edu.cn/hoj/problem/view?id=1610N个物品 每个问题K个答案 问最多问几个问题可以确定某个物品取对数即可#include #include int main(){ double n, k, m; while (scanf("%lf %lf", &k, &n) != EOF) {
2012-11-25 00:11:16
171
原创 HOJ 1637 HangOver
http://acm.hit.edu.cn/hoj/problem/view?id=1637#include #include int fun(double c);int main(){ double c; while (scanf("%lf", &c) && c) { printf("%d card(s)\n", fun(c));
2012-11-25 00:11:15
173
原创 HOJ 1649 Count on Canton
http://acm.hit.edu.cn/hoj/problem/view?id=1649前15个数为1/1 1/2 2/1 3/1 2/2 1/3 1/4 2/3 3/2 4/1 5/1 4/2 3/3 2/4 1/5从对角线上数奇数对角线从下往上 偶数对角线从上往下#include #include int main(){ int n, k; in
2012-11-25 00:11:13
236
原创 HOJ 1655 Yeehaa!
http://acm.hit.edu.cn/hoj/problem/view?id=1655给出大圆半径和小圆个数计算小圆半径 连接大圆和小圆圆心注意格式#include #include int main(){ int t, i; double R, n, r; const double pi = acos(-1); sc
2012-11-25 00:11:11
229
原创 HOJ 1684 Symmetric Order
http://acm.hit.edu.cn/hoj/problem/view?id=1684#include int main(){ char str[16][32]; int n, count = 1; int i, j; while (scanf("%d", &n) && n) { for (i = 1; i <= n; i+
2012-11-25 00:11:09
227
原创 HOJ 1685 Flow Layout
http://acm.hit.edu.cn/hoj/problem/view?id=1685一行放不下另起一行#include int main(){ int m, maxw, width, maxh, height, sumw, sumh; while (scanf("%d", &m) && m) { maxw = sumw = 0, ma
2012-11-25 00:11:07
209
原创 HOJ 1688 Speed Limit
http://acm.hit.edu.cn/hoj/problem/view?id=1688计算距离#include int main(){ int i, n, v, distance, nextime, pretime; scanf("%d",&n); while (n != -1) { distance = pretime = 0
2012-11-25 00:11:06
824
原创 HOJ 2519 Fake coin
http://acm.hit.edu.cn/hoj/problem/view?id=2519分成3堆以sample in 20为例①6 6 8若fake在6②2 2 2③1 1若fake在8②3 3 2③1 1 1或1 1#include #include int main(){ int cases, n , m; scanf("%
2012-11-25 00:11:05
303
原创 HOJ 2567 Pell
http://acm.hit.edu.cn/hoj/problem/view?id=2567#include int main(){ int cases, n, x, y; scanf("%d", &cases); while (cases--) { scanf("%d %d %d", &n, &x, &y); if (
2012-11-25 00:11:02
164
原创 HOJ 1696 No Brainer
http://acm.hit.edu.cn/hoj/problem/view?id=1696#include int main(){ int cases, x, y; scanf("%d", &cases); while (cases--) { scanf("%d %d", &x, &y); if (x < y)
2012-11-23 23:21:43
237
原创 HOJ 1746 Filling Out the Team
http://acm.hit.edu.cn/hoj/problem/view?id=1746计算此人可以胜任的位置#include int main(){ double speed, weight, strength; bool flag; while (scanf("%lf %lf %lf", &speed, &weight, &strength) !=
2012-11-23 23:21:39
200
原创 HOJ 1853 WERTYU
http://acm.hit.edu.cn/hoj/problem/view?id=1853输入字符 输出键盘上该字符左边的字符#include char s[48]="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";void transfrom(char c);int main(){ char str[100];
2012-11-23 23:21:36
277
原创 HOJ 1863 整数的排序
http://acm.hit.edu.cn/hoj/problem/view?id=1863顺便复习冒泡和选择#include#includeint compar(const void *a, const void *b);void select_sort(int a[], int n);void bubble_sort(int a[], int n);int main()
2012-11-23 23:21:33
212
原创 HOJ 1866 猩猩点灯
http://acm.hit.edu.cn/hoj/problem/view?id=1866找规律 只有序号为i^2 (1#include#includeint main(){ int k; while (scanf("%d" ,&k) && k) printf("%d\n", (int)sqrt(k)); return 0;}
2012-11-23 23:21:29
608
1
原创 HOJ 1951 Beavergnaw
http://acm.hit.edu.cn/hoj/problem/view?id=1951给出树干的直径和被松鼠啃去的体积 计算剩下树干的直径#include #include int main(){ const double pi = acos(-1); int d, v;//D, V double diameter, tmp; whi
2012-11-23 13:21:54
223
原创 HOJ 1962 Above Average
http://acm.hit.edu.cn/hoj/problem/view?id=1962计算平均分上人数占总人数的百分比#include int main(){ int cases, n, a[1000], i, count, sum; double rate, avg; count = sum = 0; scanf("%d", &cases);
2012-11-23 13:21:52
242
原创 HOJ 1976 Calendar
http://acm.hit.edu.cn/hoj/problem/view?id=19762000-01-01是星期六#include int isrun(int x);int main(){ char week[7][10] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "
2012-11-23 13:21:50
198
原创 HOJ 2012 Sort and Merge
http://acm.hit.edu.cn/hoj/problem/view?id=2012给出n个正整数 拿出两个最小的数字 把这两个数字的和-1放回原先的整数表中 重复操作 直到表中只有一个元素为止骗人的题 不用排序 #include int main(){ int num[10000]; int n, result, sum, i; whi
2012-11-23 13:21:48
231
原创 HOJ 2016 Conic Distance
http://acm.hit.edu.cn/hoj/problem/view?id=2016给出两个点的 计算这两点在圆锥面上的最短距离把圆锥展开为扇形 两点间距离利用余弦定理计算注意角度#include #include double min(double a, double b);int main(){ const double pi=acos(-1);
2012-11-23 13:21:46
261
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人