All Posts

hdoj2003解题报告

Problem Description 求实数的绝对值。   Input 输入数据有多组,每组占一行,每行包含一个实数。   Output 对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。   #include int main() {     double x;     while (scanf("%lf", &x) != EOF)     {         x = x 0 ? x : -x;         printf("%.2lfn", x);     } return 0; }

安装Ubuntu后,图形界面下修改Windows的为默认操作系统,并且更新Ubuntu后不变

操作: 在Ubuntu下Alt + Ctrl + T打开终端,输入 sudo nautilus 这时,文件管理器会打开 进入 /etc/grub.d 目录 把 30_os-prober 改为 06_os-prober 然后打开终端,输入 sudo update-grub 然后…..然后…..然后就修改成功了,简单吧

嘿嘿,碰到了坑爹的题

Problem Description Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".   Input each test case contains two numbers A and B.   Output for each case, if A is equal to B, you should print "YES", or print "NO".   Sample Input 1 2 2 2 3 3 4 3

hdoj2002解题报告

Problem Description 根据输入的半径值,计算球的体积。   Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。   Output 输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。 #include int main() { const double PI = 3.1415927; double r; while (scanf("%lf", &r) != EOF) { double v = 4 * PI * r * r * r / 3; printf("%.3lfn", v); } return 0; }

hdoj2001解题报告

Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。   Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。   Output 对于每组输入数据,输出一行,结果保留两位小数。 #include #include int main() { double a, b, x, y; while (scanf("%lf %lf %lf %lf", &a, &b, &x, &y) != EOF) { double l = sqrt((a - x) * (a - x) + (b - y) * (b - y)); printf("%.2lfn", l); } return 0; }

hdoj1002解题报告

题意:两个大数相加,按要求输出 代码如下:(未通过,但自己觉得算法正确,自测数据正常) #include #include using namespace std; int main() { int t; cin t; for (int m = 1; m a b; char ta[1000] = { 0 }, tb[1000] = { 0 }, sum[1001] = { 0 }; int la = strlen(a); int lb = strlen(b); for (int i = la - 1, j = 999; i = 0; i--, j--) ta[j] = a[i] - '0'; //复制并对齐到最后并转换成数字,方便计算 for (int i = lb - 1, j = 999; i = 0; i--, j--) tb[j] = b[i] - '0'; //同上 int pos = 0; int i = 999; do { int tmp = ta[i] + tb[i] + pos; pos = tmp / 10; sum[i + 1] = tmp % 10 + '0'; i--; } while (ta[i + 1] !

hdoj1049解题报告

题意:1个长1英寸的虫子要从高n英寸的洞里爬出来,每分钟爬u英寸,但每爬一分钟需要休息一分钟,它会下滑d英寸,问它多长时间爬出来 分析:相当于每两分钟爬u – d英寸, 但最后一次是直接爬上去的,不会下滑,这是一种方法,我用的是直接模拟这个过程的方法. 代码如下: #include using namespace std; int main() { int n, u, d; while (cin n u d) { if (n == 0)break; int t; int l = 0; for (t = 1; l

hdoj1008解题报告

题意: 坐电梯,上一层楼需要6秒,下一层楼需要4秒,在每一层会停留5秒,电梯开始在0层,输入要去的各个层,输出所需要的时间 #include using namespace std; int main() { int n; int step[101] = {0}; while (true) { cin n; if (!n)break; int time = 0; step[0] = 0; for (int i = 1; i step[i]; for (int i = 1; i step[i - 1]) { time += 6 \* (step[i] - step[i - 1]); } else { time += 4 \* (step[i - 1] - step[i]); } } time += n * 5; cout

hdoj1005解题报告

题意: f(1) = 1, f(2) = 1,  f(n) = (A * f(n – 1) + B * f(n – 2)) mod 7. 输入A,B和n,输出f(n); #include using namespace std; int main() { int f[1010]; int A, B; int64_t n; while (cin) { f[1] = 1, f[2] = 1; cin >> A >> B >> n; if ( A == 0 && B == 0 && n == 0)break; int i; for (i = 3; i <= n; i++) { f[i] = (A * f[i - 1] + B * f[i - 2]) % 7; for(int j=2;j

hdoj1004解题报告

题意:输入各种颜色的气球,输出气球数量最多的气球的颜色 #include #include using namespace std; int main() { int n; char ball\[1001\]\[40\]; while (true) { cin n; if (n == 0)break; int count[1001] = {0}; for (int i = 0; i ball[i]; } for (int i = 0; i max) { max = count[i]; pos = i; } } cout