[关闭]
@jtahstu 2016-01-09T19:59:30.000000Z 字数 35310 阅读 2966

AKOJ Problem1100-1199 C#代码汇总

C# ACM Code


1100 连续和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1100 {
  6. class Program {
  7. static void Main(string[] args) {
  8. long n = Convert.ToInt64(Console.ReadLine());
  9. long sum = (1 + n) * n / 2;
  10. Console.WriteLine("{0}", sum);
  11. }
  12. }
  13. }

1101 正弦和余弦

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1101 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int x = int.Parse(Console.ReadLine());
  9. double PI = Math.Atan(1.0) * 4.0;
  10. double s = Math.Sin(x * PI / 180);
  11. double b = Math.Cos(x * PI / 180);
  12. Console.WriteLine(s.ToString("0.000") + " " + b.ToString("0.000"));
  13. }
  14. }
  15. }

1102 两点距离

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1102 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] values = Console.ReadLine().Split(' ');
  9. double x1 = double.Parse(values[0]), y1 = double.Parse(values[1]);
  10. double x2 = double.Parse(values[2]), y2 = double.Parse(values[3]);
  11. double l = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  12. string s = l.ToString("0.000");
  13. Console.WriteLine(s);
  14. }
  15. }
  16. }

1103 偶数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1103 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = Convert.ToInt32(Console.ReadLine());
  9. if (n % 2 == 0)
  10. Console.WriteLine("yes");
  11. else
  12. Console.WriteLine("no");
  13. }
  14. }
  15. }

1104 打折

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1104 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = Convert.ToInt32(Console.ReadLine());
  9. if (n >= 4) {
  10. double s = n * 95 * 0.85;
  11. string res = s.ToString("0.00");
  12. Console.WriteLine(res);
  13. } else {
  14. Console.WriteLine("{0}", n * 95);
  15. }
  16. }
  17. }
  18. }

1105 绝对值

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1105 {
  6. class Program {
  7. static void Main(string[] args) {
  8. double n = Convert.ToDouble(Console.ReadLine());
  9. if (n >= 0) {
  10. string str = n.ToString("0.00");
  11. Console.WriteLine(str);
  12. } else {
  13. n = -n;
  14. string str = n.ToString("0.00");
  15. Console.WriteLine(str);
  16. }
  17. }
  18. }
  19. }

1106 三角形

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1106 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int[] a = new int[3];
  9. string[] values = Console.ReadLine().Split(' ');
  10. a[0] = int.Parse(values[0]); a[1] = int.Parse(values[1]); a[2] = int.Parse(values[2]);
  11. Array.Sort(a);
  12. if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
  13. Console.WriteLine("yes");
  14. else if (a[0] + a[1] <= a[2] || a[2] - a[1] >= a[0])
  15. Console.WriteLine("not a triangle");
  16. else
  17. Console.WriteLine("no");
  18. }
  19. }
  20. }

1107 闰年

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1107 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = Convert.ToInt32(Console.ReadLine());
  9. if ((n % 4 == 0 && n % 100 != 0) || n % 400 == 0) {
  10. Console.WriteLine("yes");
  11. } else {
  12. Console.WriteLine("no");
  13. }
  14. }
  15. }
  16. }

1108 最简单的循环

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1108 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. for (int i = 1; i <= n; i++) {
  10. Console.WriteLine(i);
  11. }
  12. }
  13. }
  14. }

1109 aabb

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1109 {
  6. class Program {
  7. static void Main(string[] args) {
  8. Console.WriteLine("7744");
  9. }
  10. }
  11. }

1110 3n+1中文版(简化版)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1110 {
  6. class Program {
  7. static long tt(long n) {
  8. long number = 0;
  9. while (n != 1) {
  10. if (n % 2 == 0)
  11. n /= 2;
  12. else
  13. n = 3 * n + 1;
  14. number++;
  15. }
  16. return number;
  17. }
  18. static void Main(string[] args) {
  19. long n = long.Parse(Console.ReadLine());
  20. Console.WriteLine(tt(n));
  21. }
  22. }
  23. }

1111 阶乘之和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1111 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int i = 1, n, s = 1, sum = 0;
  9. n = int.Parse(Console.ReadLine());
  10. while (i <= n) {
  11. s *= i;
  12. s %= 1000000;
  13. sum += s;
  14. i++;
  15. }
  16. sum %= 1000000;
  17. Console.WriteLine(sum);
  18. }
  19. }
  20. }

1112 简单数据统计

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. namespace AK1112 {
  7. class Program {
  8. static void Main(string[] args) {
  9. string[] s = Regex.Split(Console.In.ReadToEnd().Trim(), @"\s+");//what's a fuck!!!
  10. int[] a = new int[1005];
  11. int max = int.Parse(s[0]), min = int.Parse(s[0]);
  12. int sum = int.Parse(s[0]);
  13. for (int i = 1; i < s.Length; i++) {
  14. a[i] = int.Parse(s[i]);
  15. if (a[i] > max) max = a[i];
  16. if (a[i] < min) min = a[i];
  17. sum += a[i];
  18. }
  19. double jt = sum * 1.0 / s.Length;
  20. Console.WriteLine("{0} {1} {2}", min, max, jt.ToString("0.000"));
  21. //Console.ReadKey();
  22. }
  23. }
  24. }

1113 位数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1113 {
  6. class Program {
  7. static void Main(string[] args) {
  8. long n = long.Parse(Console.ReadLine()), i = 0;
  9. while (n > 0) {
  10. i++;
  11. n /= 10;
  12. }
  13. Console.WriteLine(i);
  14. }
  15. }
  16. }

1114 水仙花数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1114 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int a, b, x, y, z, i;
  9. string[] values = Console.ReadLine().Split(' ');
  10. a = int.Parse(values[0]); b = int.Parse(values[1]);
  11. if (a < 100) a = 100;
  12. if (b > 999) b = 999;
  13. for (i = a; i <= b; i++) {
  14. x = i / 100;
  15. y = i / 10 % 10;
  16. z = i % 10;
  17. if (x * x * x + y * y * y + z * z * z == i)
  18. Console.WriteLine(i);
  19. }
  20. }
  21. }
  22. }

1115 韩信点兵

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1115 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int a = int.Parse(s[0]), b = int.Parse(s[1]), c = int.Parse(s[2]);
  12. bool flag = false;
  13. for (int i = 10; i <= 100; i++) {
  14. if (i % 3 == a && i % 5 == b && i % 7 == c) {
  15. flag = true;
  16. Console.WriteLine(i);
  17. break;
  18. }
  19. }
  20. if (!flag)
  21. Console.WriteLine("No answer");
  22. }
  23. }
  24. }
  25. }

1116 倒三角形

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1116 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. for (int i = 0; i < n; i++) {
  10. for (int j = 1; j <= 2 * n - i - 1; j++) {
  11. if (i >= j)
  12. Console.Write(" ");
  13. else
  14. Console.Write("#");
  15. }
  16. Console.WriteLine();
  17. }
  18. }
  19. }
  20. }

1117 简单统计

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1117 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. string[] a = Console.ReadLine().Split(' ');
  12. int m = int.Parse(Console.ReadLine());
  13. int count = 0;
  14. for (int i = 0; i < n; i++) {
  15. if (int.Parse(a[i]) < m)
  16. count++;
  17. }
  18. Console.WriteLine(count);
  19. }
  20. }
  21. }
  22. }

1118 调和级数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1118 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. double sum = 0;
  12. for (int i = 1; i <= n; i++) {
  13. sum += 1.0 / i;
  14. }
  15. Console.WriteLine(sum.ToString("0.000"));
  16. }
  17. }
  18. }
  19. }

1119 近似计算

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1119 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. double sum = 0;
  12. int sign = 1;
  13. for (int i = 1; i <= n; i += 2) {
  14. sum += 1.0 / i * sign;
  15. sign *= -1;
  16. }
  17. sum *= 4.0;
  18. Console.WriteLine(sum.ToString("0.000000"));
  19. }
  20. }
  21. }
  22. }

1120 子序列的和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1120 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. long n = long.Parse(s[0]), m = long.Parse(s[1]);
  12. double sum = 0;
  13. for (long i = n; i <= m; i++) {
  14. sum += (1.0 / (i * i));
  15. }
  16. Console.WriteLine(sum.ToString("0.00000"));
  17. }
  18. }
  19. }
  20. }

1121 分数化小数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Ak1121 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int a = int.Parse(s[0]), b = int.Parse(s[1]), c = int.Parse(s[2]);
  12. int integer = a / b;//整数部分
  13. a = a % b;
  14. int[] ans = new int[105];
  15. for (int i = 0; i <= c; i++) {
  16. ans[i] = a * 10 / b;
  17. a = a * 10 % b;
  18. }
  19. int jt = 0;//用于四舍五入
  20. if (ans[c] > 5) {
  21. jt = 1;
  22. for (int i = c - 1; i >= 0; i--)//处理后面来的的进位
  23. {
  24. ans[i] = (ans[i] + jt) % 10;
  25. jt = ans[i] / 10;
  26. if (jt == 0) break;
  27. }
  28. }
  29. Console.Write(integer + ".");
  30. for (int i = 0; i < c; i++)
  31. Console.Write(ans[i]);
  32. Console.WriteLine();
  33. }
  34. }
  35. }
  36. }

1122 排列

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace AK1122 {
  7. class Program {
  8. static void Main(string[] args) {
  9. Console.WriteLine("192 384 576\n219 438 657\n273 546 819\n327 654 981");
  10. }
  11. }
  12. }

1123 A+B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1123 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] s = Console.ReadLine().Split();
  9. int a = int.Parse(s[0]), b = int.Parse(s[1]);
  10. Console.WriteLine(a + b);
  11. //Console.ReadLine();
  12. }
  13. }
  14. }

1124 计算a的立方

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1124 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. long n = long.Parse(sb);
  11. long ans = n * n * n;
  12. Console.WriteLine(ans);
  13. }
  14. }
  15. }
  16. }

1125 小写字母变为大写字母

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1125 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb = Console.ReadLine();
  9. for (int i = 0; i < sb.Length; i++) {
  10. if (sb[i] >= 'a' && sb[i] <= 'z')
  11. Console.Write(sb[i].ToString().ToUpper());
  12. else
  13. Console.Write(sb[i]);
  14. }
  15. Console.WriteLine();
  16. //Console.ReadLine();
  17. }
  18. }
  19. }

1126 小明A+B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1126 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. int a = int.Parse(sb[0]), b = int.Parse(sb[1]);
  10. int x = (a / 10 + b / 10) % 10;
  11. int y = (a % 10 + b % 10) % 10;
  12. if (x == 0)
  13. Console.WriteLine(y);
  14. else
  15. Console.WriteLine("{0}{1}", x, y);
  16. //Console.ReadKey();
  17. }
  18. }
  19. }

1127 计算阶乘和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1127 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. long sum = 0, count = 1;
  10. for (int i = 1; i <= n; i++) {
  11. count *= i;
  12. sum += count;
  13. }
  14. Console.WriteLine(sum);
  15. //Console.ReadLine();
  16. }
  17. }
  18. }

1128 整数排序

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1128 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] s = Console.ReadLine().Split();
  9. int[] a = new int[10];
  10. for (int i = 0; i < 10; i++)
  11. a[i] = int.Parse(s[i]);
  12. Array.Sort(a);
  13. foreach (int i in a)
  14. Console.Write(i + " ");
  15. Console.WriteLine();
  16. //Console.ReadLine();
  17. }
  18. }
  19. }

1129 找用户名

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1129 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s = Console.ReadLine();
  9. int i = s.IndexOf('@');
  10. string b = s.Substring(0, i);
  11. Console.WriteLine(b);
  12. //Console.ReadLine();
  13. }
  14. }
  15. }

1130 矩阵找值

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1130 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] s;
  9. int[,] a = new int[5, 5];
  10. int max = -100000000, ii = 0, jj = 0;
  11. for (int i = 0; i < 4; i++) {
  12. s = Console.ReadLine().Split();
  13. for (int j = 0; j < 3; j++) {
  14. a[i, j] = int.Parse(s[j]);
  15. if (a[i, j] > max) {
  16. max = a[i, j];
  17. ii = i;
  18. jj = j;
  19. }
  20. }
  21. }
  22. Console.WriteLine("{0} {1} {2}", max, ii, jj);
  23. //Console.ReadLine();
  24. }
  25. }
  26. }

1131 数列求和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1131 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. int a = 2, b = 1;
  10. double sum = 0;
  11. for (int i = 0; i < n; i++) {
  12. sum += a * 1.0 / b;
  13. int c = a;
  14. a = a + b;
  15. b = c;
  16. }
  17. Console.WriteLine(sum.ToString("0.000"));
  18. //Console.ReadLine();
  19. }
  20. }
  21. }

1132 三角形面积

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1132 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] s = Console.ReadLine().Split();
  9. double[] a = new double[3];
  10. for (int i = 0; i < 3; i++)
  11. a[i] = double.Parse(s[i]);
  12. Array.Sort(a);
  13. if (a[2] - a[0] >= a[1])
  14. Console.WriteLine("Input error!");
  15. else {
  16. double b = (a[0] + a[1] + a[2]) / 2;
  17. double c = Math.Sqrt(b * (b - a[0]) * (b - a[1]) * (b - a[2]));
  18. Console.WriteLine(c.ToString("0.00"));
  19. }
  20. //Console.ReadLine();
  21. }
  22. }
  23. }

1133 最近平方数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1133 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. int x = (int)Math.Sqrt(n * 1.0);
  10. if (x * x == n)
  11. Console.WriteLine(n);
  12. else {
  13. if (Math.Abs((x + 1) * (x + 1) - n) < Math.Abs((x) * (x) - n))//这里比较的是n和n+1
  14. Console.WriteLine((x + 1) * (x + 1));
  15. else
  16. Console.WriteLine((x) * (x));
  17. }
  18. }
  19. }
  20. }

1134 区间质数统计

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1134 {
  6. class Program {
  7. static bool prime(int n) {
  8. if (n == 1) return false;
  9. if (n == 2) return true;
  10. for (int i = 2; i * i <= n; i++)
  11. if (n % i == 0)
  12. return false;
  13. return true;
  14. }
  15. static void Main(string[] args) {
  16. string[] s = Console.ReadLine().Split();
  17. int[] a = new int[2];
  18. int n = int.Parse(s[0]), m = int.Parse(s[1]);
  19. int count = 0;
  20. for (int i = n; i <= m; i++)
  21. if (prime(i))
  22. count++;
  23. Console.WriteLine(count);
  24. }
  25. }
  26. }

1135 逆转字符串

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1135 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s = Console.ReadLine();
  9. for (int i = s.Length - 1; i >= 0; i--)
  10. Console.Write(s[i]);
  11. Console.WriteLine();
  12. }
  13. }
  14. }

1136 敲7

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1136 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. for (int i = 1; i <= n; i++) {
  10. if (i % 7 == 0 || i % 10 == 7 || i / 10 % 10 == 7 || i / 100 % 10 == 7)
  11. Console.WriteLine(i);
  12. }
  13. }
  14. }
  15. }

1137 新年快乐!

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1137 {
  6. class Program {
  7. static void Main(string[] args) {
  8. Console.WriteLine("Happy new year \"2014\"");
  9. }
  10. }
  11. }

1138 游程编码

1139 二维序列查找

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1139 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string[] s = Console.ReadLine().Split();
  11. int a = int.Parse(s[0]), b = int.Parse(s[1]);
  12. Console.WriteLine((a + b) * (a + b + 1) / 2 + a + 1);
  13. }
  14. }
  15. }
  16. }

1140 英雄联盟阵营

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1140 {
  6. /// <summary>
  7. /// 这道题就是千万不要想太多,数据不难,这题和连接电脑那题差不多
  8. /// </summary>
  9. class Program {
  10. static void Main(string[] args) {
  11. string[] s = Console.ReadLine().Split();
  12. int n = int.Parse(s[0]), m = int.Parse(s[1]);
  13. string[] b = Console.ReadLine().Split();
  14. int[] a = new int[205];
  15. int count = 1;
  16. a[int.Parse(b[0])] = count;
  17. a[int.Parse(b[1])] = count;
  18. for (int i = 1; i < m; i++) {
  19. string[] sb = Console.ReadLine().Split();
  20. int p = int.Parse(sb[0]), q = int.Parse(sb[1]);
  21. if (a[p] != 0) a[q] = count;
  22. else {
  23. count++;
  24. a[p] = count;
  25. a[q] = a[p];
  26. }
  27. }
  28. Console.WriteLine(count);
  29. }
  30. }
  31. }

1141 n%m

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1141 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int t = int.Parse(Console.ReadLine());
  9. while (t-- > 0) {
  10. string[] a = Console.ReadLine().Split();
  11. long n = long.Parse(a[0]), m = long.Parse(a[1]);
  12. long sum = 0;
  13. for (int i = 1; i <= n; i++)
  14. sum += i % m;
  15. Console.WriteLine(sum);
  16. }
  17. }
  18. }
  19. }

1142 同构词

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1142 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string[] s = Console.ReadLine().Split();
  11. string a = s[0], b = s[1];
  12. int[] p = new int[26], q = new int[26];
  13. for (int i = 0; i < a.Length; i++) {
  14. p[a[i] - 'a']++;
  15. }
  16. for (int i = 0; i < b.Length; i++) {
  17. q[b[i] - 'a']++;
  18. }
  19. bool flag = true;
  20. for (int i = 0; i < 26; i++) {
  21. if ((p[i] == 0 && q[i] != 0) || (p[i] != 0 && q[i] == 0)) flag = false;
  22. }
  23. if (flag)
  24. Console.WriteLine("Yes");
  25. else
  26. Console.WriteLine("No");
  27. }
  28. }
  29. }
  30. }

1143 函数解析式

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1143 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int[] a = new int[10005];
  9. a[0] = 1;
  10. for (int i = 1; i < 10001; i++)
  11. a[i] = a[i - 1] + 2 * (i - 1);
  12. int n = int.Parse(Console.ReadLine());
  13. while (n-- > 0) {
  14. int x = int.Parse(Console.ReadLine());
  15. Console.WriteLine(a[x]);
  16. }
  17. }
  18. }
  19. }

1144 光辉女郎之终极闪光

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1144 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. int[] a = new int[1001], b = new int[1001];
  10. double[] k = new double[1001];
  11. for (int i = 0; i < n; i++) {
  12. string[] sb = Console.ReadLine().Split();
  13. a[i] = int.Parse(sb[0]);
  14. b[i] = int.Parse(sb[1]);
  15. k[i] = 1.0 * a[i] / b[i];
  16. }
  17. Array.Sort(k, 0, n);
  18. int count = 1, max = 0;
  19. for (int i = 1; i < n; i++) {
  20. if (k[i] == k[i - 1]) {
  21. count++;
  22. if (count > max)
  23. max = count;
  24. } else count = 1;
  25. }
  26. Console.WriteLine(max);
  27. }
  28. }
  29. }

1145 ACMer

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1145 {
  6. class Program {
  7. static void Main(string[] args) {
  8. Console.WriteLine("I am an \"ACMer\", I love \"ACM\".");
  9. //Console.ReadKey();
  10. }
  11. }
  12. }

1146 结义兄弟

1147 小周的烦恼

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1147 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. int m = int.Parse(Console.ReadLine());
  11. int[] a = new int[10];
  12. int max = 0, len = (int)Math.Log10(m * 1.0) + 1, i, j, s;
  13. //Console.WriteLine(len);
  14. max = m / 10;
  15. for (i = len - 1; i >= 0; i--) {
  16. a[i] = m % 10;
  17. m /= 10;
  18. }
  19. for (i = 0; i < len; i++)//删除第i位,然后把这个数与max比较,遍历一遍得最大值
  20. {
  21. s = 0;
  22. for (j = 0; j < len; j++) {
  23. if (i == j) continue;
  24. s = s * 10 + a[j];
  25. }
  26. if (s > max) max = s;
  27. }
  28. Console.WriteLine(max);
  29. }
  30. }
  31. }
  32. }

1148 小光棍数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1148 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. long x = long.Parse(Console.ReadLine());
  11. Console.WriteLine("{0}471", x - 1);
  12. }
  13. }
  14. }
  15. }

1149 光棍节的快乐
1150 寻找最大数

1151 key数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1151 {
  6. class Program {
  7. static int fun(int n, int d)//整数转化为d进制的各个位之和
  8. {
  9. int sum = 0, a;
  10. while (n > 0) {
  11. a = n % d;
  12. sum += a;
  13. n /= d;
  14. }
  15. return sum;
  16. }
  17. static void Main(string[] args) {
  18. string sb;
  19. while ((sb = Console.ReadLine()) != null) {
  20. int n = int.Parse(sb);
  21. if (n == 0) break;
  22. if (fun(n, 10) == fun(n, 12) && fun(n, 12) == fun(n, 16))
  23. Console.WriteLine("{0} is a Sky Number.", n);
  24. else
  25. Console.WriteLine("{0} is not a Sky Number.", n);
  26. }
  27. }
  28. }
  29. }

1152 整除个数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1152 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. long a = long.Parse(s[0]), b = long.Parse(s[1]);
  12. Console.WriteLine(a / b);
  13. }
  14. }
  15. }
  16. }

1153 p次方求和

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1153 {
  6. class Program {
  7. static int erfen(int n, int p) {
  8. int a = n;
  9. int b = p;
  10. int result = 1;
  11. while (b != 0) {
  12. if (b % 2 == 1) {
  13. result = (result * a) % 10003; //乘一个a,也就是i
  14. }
  15. a = (a * a) % 10003; //平方
  16. b /= 2; //把这个数截一半
  17. }
  18. return result;
  19. }
  20. static void Main(string[] args) {
  21. int t = int.Parse(Console.ReadLine());
  22. while (t-- > 0) {
  23. string[] sb = Console.ReadLine().Split();
  24. int n = int.Parse(sb[0]), p = int.Parse(sb[1]);
  25. int sum = 0;
  26. for (int i = 1; i <= n; i++)
  27. sum = (sum + erfen(i, p)) % 10003;
  28. Console.WriteLine(sum);
  29. }
  30. }
  31. }
  32. }

1154 算菜价
1155 Problem of IP
1156 分数加减法

1157 茵茵的第一课

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1157 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s;
  9. while ((s = Console.ReadLine()) != null) {
  10. int n = int.Parse(s);
  11. while (n-- > 0) {
  12. string sb = Console.ReadLine();
  13. Console.WriteLine(sb);
  14. }
  15. }
  16. }
  17. }
  18. }

1158 关于521

1159 GrassLand密码

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1159 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. for (int i = 0; i < sb.Length; i++) {
  11. if (sb[i] == 'a' || sb[i] == 'b' || sb[i] == 'c') Console.Write("2");
  12. if (sb[i] == 'd' || sb[i] == 'e' || sb[i] == 'f') Console.Write("3");
  13. if (sb[i] == 'g' || sb[i] == 'h' || sb[i] == 'i') Console.Write("4");
  14. if (sb[i] == 'j' || sb[i] == 'k' || sb[i] == 'l') Console.Write("5");
  15. if (sb[i] == 'm' || sb[i] == 'n' || sb[i] == 'o') Console.Write("6");
  16. if (sb[i] == 'p' || sb[i] == 'p' || sb[i] == 'r' || sb[i] == 's') Console.Write("7");
  17. if (sb[i] == 't' || sb[i] == 'u' || sb[i] == 'v') Console.Write("8");
  18. if (sb[i] == 'w' || sb[i] == 'x' || sb[i] == 'y' || sb[i] == 'z') Console.Write("9");
  19. }
  20. Console.WriteLine();
  21. }
  22. }
  23. }
  24. }

1160 寻找大富翁

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1160 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int n = int.Parse(s[0]), m = int.Parse(s[1]);
  12. if (n + m == 0) break;
  13. string[] b = Console.ReadLine().Split();
  14. int[] count = new int[1100];
  15. for (int i = 0; i < n; i++)
  16. count[i] = int.Parse(b[i]);
  17. Array.Sort(count, 0, n);
  18. for (int i = n - 1; i >= n - m; i--)
  19. Console.Write(count[i] + " ");
  20. Console.WriteLine();
  21. }
  22. }
  23. }
  24. }

1161 路径打印
1162 计算表达式

1163 AOJ

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1163 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. if (sb.Equals("E")) break;
  11. int a = 0, o = 0, j = 0;
  12. for (int i = 0; i < sb.Length; i++) {
  13. if (sb[i] == 'A')
  14. a++;
  15. if (sb[i] == 'O')
  16. o++;
  17. if (sb[i] == 'J')
  18. j++;
  19. }
  20. while (a > 0 && o > 0 && j > 0) {
  21. Console.Write("AOJ");
  22. a--;
  23. o--;
  24. j--;
  25. }
  26. while (a > 0 && o > 0) {
  27. Console.Write("AO");
  28. a--;
  29. o--;
  30. }
  31. while (a > 0 && j > 0) {
  32. Console.Write("AJ");
  33. a--;
  34. j--;
  35. }
  36. while (o > 0 && j > 0) {
  37. Console.Write("OJ");
  38. o--;
  39. j--;
  40. }
  41. while (a > 0) {
  42. Console.Write("A");
  43. a--;
  44. }
  45. while (o > 0) {
  46. Console.Write("O");
  47. o--;
  48. }
  49. while (j > 0) {
  50. Console.Write("J");
  51. j--;
  52. }
  53. Console.WriteLine();
  54. }
  55. }
  56. }
  57. }

1164 判断三角形类型

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1164 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. double[] a = new double[3];
  12. a[0] = double.Parse(s[0]);
  13. a[1] = double.Parse(s[1]);
  14. a[2] = double.Parse(s[2]);
  15. Array.Sort(a, 0, 3);
  16. if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])//钝角三角形
  17. Console.WriteLine("Obtuse Triangle");
  18. if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])//直角三角形
  19. Console.WriteLine("Rect Triangle");
  20. if (a[0] * a[0] + a[1] * a[1] > a[2] * a[2])//锐角三角形
  21. Console.WriteLine("Actue Triangle");
  22. }
  23. }
  24. }
  25. }

1165 矩形的个数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1165 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int a = int.Parse(s[0]), b = int.Parse(s[1]);
  12. int c = 0, sum1 = 0, sum2 = 0;
  13. for (int i = 1; i <= a; i++)
  14. sum1 += i;
  15. for (int n = 1; n <= b; n++)
  16. sum2 += n;
  17. c = sum1 * sum2;
  18. Console.WriteLine(c);
  19. }
  20. }
  21. }
  22. }

1166 交换输出

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1166 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int n = int.Parse(s[0]);
  12. if (n == 0) break;
  13. int[] a = new int[105];
  14. int min = 100000000, x = 0;
  15. for (int i = 1; i <= n; i++) {
  16. a[i] = int.Parse(s[i]);
  17. if (a[i] < min) { min = a[i]; x = i; }
  18. }
  19. a[x] = a[1];
  20. a[1] = min;
  21. for (int i = 1; i <= n; i++)
  22. Console.Write(a[i] + " ");
  23. Console.WriteLine();
  24. }
  25. }
  26. }
  27. }

1167 变态最大值

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1167 {
  6. class Program {
  7. static int max(int a, int b, int c) {
  8. int max = a;
  9. if (b > max) max = b;
  10. if (c > max) max = c;
  11. return max;
  12. }
  13. static int min(int a, int b, int c) {
  14. int min = a;
  15. if (b < min) min = b;
  16. if (c < min) min = c;
  17. return min;
  18. }
  19. static void Main(string[] args) {
  20. string sb;
  21. while ((sb = Console.ReadLine()) != null) {
  22. int n = int.Parse(sb);
  23. int[] a = new int[11000];
  24. string[] s = Console.ReadLine().Split();
  25. for (int i = 0; i < n; i++)
  26. a[i] = int.Parse(s[i]);
  27. int x, maxx = -100000000;
  28. for (int i = 0; i < n - 2; i += 3) {
  29. if ((i / 3) % 2 == 0)//奇数组求最大
  30. x = max(a[i], a[i + 1], a[i + 2]);
  31. else//偶数组求最小
  32. x = min(a[i], a[i + 1], a[i + 2]);
  33. if (x > maxx) maxx = x;//找最大
  34. }
  35. Console.WriteLine(maxx);
  36. }
  37. }
  38. }
  39. }

1168 奋斗的小蜗牛

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1168 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. int h = int.Parse(Console.ReadLine());
  11. if (h <= 10) Console.WriteLine("1");
  12. else {
  13. if (h % 5 == 0)
  14. Console.WriteLine(h / 5 - 1);
  15. else
  16. Console.WriteLine(h / 5);
  17. }
  18. }
  19. }
  20. }
  21. }

1169 车牌号

1170 国王的魔镜

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1170 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string a = Console.ReadLine();
  11. if (a.Length % 2 == 1) { Console.WriteLine(a.Length); continue; }
  12. int count = a.Length;
  13. bool flag = true;
  14. while (count % 2 != 1) {
  15. for (int i = 0, j = count - 1; i < count / 2; i++, j--) {
  16. if (a[i] == a[j]) continue;
  17. else flag = false;
  18. }
  19. if (flag) count = count / 2;//如果对半比较都一样,折半
  20. else { Console.WriteLine(count); break; }//否则输出长度
  21. }
  22. if (flag) Console.WriteLine(count);//如果最后是1了,输出
  23. }
  24. }
  25. }
  26. }

1171 荷兰国旗问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1171 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string s = Console.ReadLine();
  11. int r = 0, w = 0, b = 0;
  12. for (int i = 0; i < s.Length; i++) {
  13. if (s[i] == 'R') r++;
  14. if (s[i] == 'W') w++;
  15. if (s[i] == 'B') b++;
  16. }
  17. for (int i = 0; i < r; i++)
  18. Console.Write("R");
  19. for (int i = 0; i < w; i++)
  20. Console.Write("W");
  21. for (int i = 0; i < b; i++)
  22. Console.Write("B");
  23. Console.WriteLine();
  24. }
  25. }
  26. }
  27. }

1172 精 挑 细 选

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1172 {
  6. /// <summary>
  7. /// 实际上这题就是简单的结构体排序,但是这样写也可以
  8. /// </summary>
  9. class Program {
  10. static void Main(string[] args) {
  11. int n = int.Parse(Console.ReadLine());
  12. while (n-- > 0) {
  13. int m = int.Parse(Console.ReadLine());
  14. int[] a = new int[1001], b = new int[1001], c = new int[1001];
  15. for (int i = 0; i < m; i++) {
  16. string[] sb = Console.ReadLine().Split();
  17. a[i] = int.Parse(sb[0]);
  18. b[i] = int.Parse(sb[1]);
  19. c[i] = int.Parse(sb[2]);
  20. }
  21. int max = 0, min = 1000000, mmax = 0;
  22. for (int i = 0; i < m; i++) if (a[i] > max) max = a[i];//先找到最长的
  23. for (int j = 0; j < m; j++) if (a[j] == max && b[j] < min) min = b[j];//然后找到最长中的最细的
  24. for (int i = 0; i < m; i++) if (a[i] == max && b[i] == min && c[i] > mmax) mmax = c[i];//然后找到最长中的最细的编码最大的
  25. Console.WriteLine(mmax);
  26. }
  27. }
  28. }
  29. }

1173 兰州烧饼

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1173 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. int n = int.Parse(sb[0]), k = int.Parse(sb[1]);
  10. if (2 * n % k == 0) Console.WriteLine(2 * n / k);//总共2n面,如果可以整除
  11. else Console.WriteLine(2 * n / k + 1);//不能整除+1
  12. }
  13. }
  14. }

1174 正三角形的外接圆面积

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1174 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. int a = int.Parse(Console.ReadLine());
  11. double pi = 3.1415926;
  12. double sb = a * a * pi / 3;
  13. Console.WriteLine(sb.ToString("0.00"));
  14. }
  15. }
  16. }
  17. }

1175 字母小游戏

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1175 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string sb = Console.ReadLine();
  11. int count = 0;
  12. for (int i = 0; i < sb.Length; i++)
  13. if (sb[i] >= 'a' && sb[i] <= 'z')
  14. count++;
  15. count %= 26;
  16. if (count == 0) Console.WriteLine("z");
  17. else Console.WriteLine((char)(count + 'a' - 1));
  18. }
  19. }
  20. }
  21. }

1177 三角形面积

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1177 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int[] a = new int[6];
  12. for (int i = 0; i < 6; i++)
  13. a[i] = int.Parse(s[i]);
  14. if (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] == 0) break;
  15. double b = Math.Sqrt((a[3] - a[1]) * (a[3] - a[1]) + (a[2] - a[0]) * (a[2] - a[0]));
  16. double c = Math.Sqrt((a[5] - a[3]) * (a[5] - a[3]) + (a[4] - a[2]) * (a[4] - a[2]));
  17. double d = Math.Sqrt((a[5] - a[1]) * (a[5] - a[1]) + (a[4] - a[0]) * (a[4] - a[0]));
  18. double q = (b + c + d) / 2;
  19. double area = Math.Sqrt(q * (q - b) * (q - c) * (q - d));
  20. Console.WriteLine(area.ToString("0.0"));
  21. }
  22. }
  23. }
  24. }

1178 笨小熊

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1178 {
  6. class Program {
  7. static bool prime(int n) {
  8. if (n == 0 || n == 1) return false;
  9. if (n == 2) return true;
  10. for (int i = 2; i * i <= n; i++)
  11. if (n % i == 0)
  12. return false;
  13. return true;
  14. }
  15. static void Main(string[] args) {
  16. int n = int.Parse(Console.ReadLine());
  17. while (n-- > 0) {
  18. string sb = Console.ReadLine();
  19. int max = -1, min = 10000;
  20. int[] a = new int[27];
  21. for (int i = 0; i < sb.Length; i++)
  22. a[sb[i] - 'a']++;
  23. for (int i = 0; i < 26; i++) {
  24. if (a[i] > max && a[i] != 0) max = a[i];
  25. if (a[i] < min && a[i] != 0) min = a[i];
  26. }
  27. if (prime(max - min)) {
  28. Console.WriteLine("Lucky Word");
  29. Console.WriteLine(max - min);
  30. } else {
  31. Console.WriteLine("No Answer");
  32. Console.WriteLine("0");
  33. }
  34. }
  35. }
  36. }
  37. }
  38. using System;
  39. using System.Collections.Generic;
  40. using System.Linq;
  41. using System.Text;
  42. namespace AK1178 {
  43. class Program {
  44. static bool prime(int n) {
  45. if (n == 0 || n == 1) return false;
  46. if (n == 2) return true;
  47. for (int i = 2; i * i <= n; i++)
  48. if (n % i == 0)
  49. return false;
  50. return true;
  51. }
  52. static void Main(string[] args) {
  53. int n = int.Parse(Console.ReadLine());
  54. while (n-- > 0) {
  55. string sb = Console.ReadLine();
  56. int max = -1, min = 10000;
  57. int[] a = new int[27];
  58. for (int i = 0; i < sb.Length; i++)
  59. a[sb[i] - 'a']++;
  60. for (int i = 0; i < 26; i++) {
  61. if (a[i] > max && a[i] != 0) max = a[i];
  62. if (a[i] < min && a[i] != 0) min = a[i];
  63. }
  64. if (prime(max - min)) {
  65. Console.WriteLine("Lucky Word");
  66. Console.WriteLine(max - min);
  67. } else {
  68. Console.WriteLine("No Answer");
  69. Console.WriteLine("0");
  70. }
  71. }
  72. }
  73. }
  74. }

1179 N!

1180 三点顺序

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1180 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int[] a = new int[6];
  12. for (int i = 0; i < 6; i++) a[i] = int.Parse(s[i]);
  13. if (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] == 0) break;
  14. //2-0 * 5-1 - 3-1 * 4-0
  15. if ((a[2] - a[0]) * (a[5] - a[1]) - (a[3] - a[1]) * (a[4] - a[0]) > 0)
  16. Console.WriteLine("0");
  17. else
  18. Console.WriteLine("1");
  19. }
  20. }
  21. }
  22. }

1181 队花的烦恼

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1181 {
  6. /// <summary>
  7. /// 也是RE,不知道测试数据是一行在一起的,还是一行一个
  8. /// 第二下AC了
  9. /// </summary>
  10. class Program {
  11. static void Main(string[] args) {
  12. string sb;
  13. while ((sb = Console.ReadLine()) != null) {
  14. string[] s = sb.Split();
  15. long n = 0;
  16. for (int k = 0; k < s.Length; k++)//这种写法不管是一行一个还是一行多个都可以处理,what's a fuck
  17. {
  18. n = long.Parse(s[k]);
  19. if (n == 0) Console.WriteLine("0");
  20. else {
  21. long[] a = new long[105];
  22. int i = 0;
  23. while (n > 0) {
  24. a[i++] = n % 2;
  25. n /= 2;
  26. }
  27. int satrt = 0;
  28. for (int j = i - 1; j >= 0; j--) if (a[j] != 0) { satrt = j; break; }
  29. for (int j = satrt; j >= 0; j--)
  30. Console.Write(a[j]);
  31. Console.WriteLine();
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }

1182 对决

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1182 {
  6. class Program {
  7. static void solve(int a, int b) {
  8. int[] s = new int[1001];
  9. bool flag = false;
  10. for (int i = 1; i <= a / 2; i++) {
  11. s[i] = i * (a - i);
  12. if (s[i] == b) {
  13. Console.WriteLine("YES");
  14. flag = true;
  15. break;
  16. }
  17. }
  18. if (!flag)
  19. Console.WriteLine("NO");
  20. }
  21. static void Main(string[] args) {
  22. string sb;
  23. while ((sb = Console.ReadLine()) != null) {
  24. string[] s = sb.Split();
  25. int a = int.Parse(s[0]), b = int.Parse(s[1]);
  26. if (a + b == 0) break;
  27. solve(a, b);
  28. }
  29. }
  30. }
  31. }

1183 整除个数(1)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1183 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. long a = long.Parse(s[0]), b = long.Parse(s[1]);
  12. Console.WriteLine(a / b);
  13. }
  14. }
  15. }
  16. }

1184 ASCII码排序(2)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1184 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string s = Console.ReadLine();
  11. int[] a = new int[3];
  12. for (int i = 0; i < 3; i++)
  13. a[i] = s[i] - 'a';
  14. Array.Sort(a);
  15. Console.WriteLine("{0} {1} {2}", (char)(a[2] + 'a'), (char)(a[1] + 'a'), (char)(a[0] + 'a'));
  16. }
  17. }
  18. }
  19. }

1185 6174问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1185 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int t = int.Parse(Console.ReadLine());
  9. while (t-- > 0) {
  10. int n = int.Parse(Console.ReadLine());
  11. int count = 1;
  12. while (n != 6174) {
  13. int[] a = new int[4];
  14. int j = 0;
  15. while (n > 0) {
  16. a[j++] = n % 10;
  17. n /= 10;
  18. }
  19. Array.Sort(a, 0, 4);
  20. int min = a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
  21. int max = a[3] * 1000 + a[2] * 100 + a[1] * 10 + a[0];
  22. n = max - min;
  23. count++;
  24. }
  25. Console.WriteLine(count);
  26. }
  27. }
  28. }
  29. }

1186 小学生算术

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1186 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int m = int.Parse(s[0]), n = int.Parse(s[1]);
  12. if (m + n == 0) break;
  13. int a = m / 100;
  14. int b = m / 10 % 10;
  15. int c = m % 10;
  16. int x = n / 100;
  17. int y = n / 10 % 10;
  18. int z = n % 10;
  19. int i = 0;
  20. if ((c + z) >= 10) { i++; b++; }
  21. if ((b + y) >= 10) { i++; a++; }
  22. if ((a + x) >= 10) { i++; }
  23. Console.WriteLine(i);
  24. }
  25. }
  26. }
  27. }

1187 开灯问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1187 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. int n = int.Parse(sb[0]), k = int.Parse(sb[1]);
  10. int[] a = new int[1001];
  11. int i, j;
  12. for (i = 1; i <= k; i++) {
  13. for (j = i; j <= n; j += i) {
  14. if (a[j] == 0)
  15. a[j] = 1;//0代表关,1代表开
  16. else
  17. a[j] = 0;
  18. }
  19. }
  20. for (i = 1; i <= n; i++)
  21. if (a[i] == 1)
  22. Console.Write(i + " ");
  23. Console.WriteLine();
  24. }
  25. }
  26. }

1188 中位数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1188 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. if (n == 0) break;
  12. else {
  13. string[] s = Console.ReadLine().Split();
  14. int[] a = new int[10005];
  15. for (int i = 0; i < n; i++)
  16. a[i] = int.Parse(s[i]);
  17. Array.Sort(a, 0, n);
  18. if (n % 2 == 1)
  19. Console.WriteLine(a[n / 2]);
  20. else
  21. Console.WriteLine(Math.Floor((a[n / 2] + a[n / 2 - 1] * 1.0) / 2));
  22. }
  23. }
  24. }
  25. }
  26. }

1189 字符串去特定字符

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1189 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string s = Console.ReadLine();
  11. for (int i = 0; i < sb.Length; i++)
  12. if (sb[i] != s[0])
  13. Console.Write(sb[i]);
  14. Console.WriteLine();
  15. }
  16. }
  17. }
  18. }

1190 找x

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1190 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. int[] a = new int[n];
  12. string[] s = Console.ReadLine().Split();
  13. for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);
  14. int x = int.Parse(Console.ReadLine());
  15. bool flag = true;
  16. for(int i=0;i<n;i++)
  17. if (a[i] == x) {
  18. flag = false;
  19. Console.WriteLine(i);
  20. break;
  21. }
  22. if (flag) Console.WriteLine("-1");
  23. }
  24. }
  25. }
  26. }

1191 喜欢二的小胖

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1191 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int[] ans = new int[10005];
  9. ans[0] = 1; ans[1] = 2; ans[2] = 0; ans[3] = 2;
  10. for (int i = 4; i <= 10000; i++)
  11. ans[i] = ans[i / 2] + 1;
  12. string sb;
  13. while ((sb = Console.ReadLine()) != null) {
  14. string[] s = sb.Split();
  15. int a = int.Parse(s[0]), b = int.Parse(s[1]);
  16. int sum = 0;
  17. for (int i = a; i <= b; i++)
  18. sum += ans[i];
  19. Console.WriteLine(sum);
  20. }
  21. }
  22. }
  23. }

1192 做一从一而终的男

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1192 {
  6. class Program {
  7. static long f(long n) {
  8. if (n == 0) return 0;
  9. long[] s = new long[40];
  10. long i = 0;
  11. while (n > 0) {//二进制转换
  12. s[i++] = n % 2;
  13. n /= 2;
  14. }
  15. int count = 1, x = 1;
  16. for (int j = 1; j < i; j++) {
  17. if (s[j] == 1 && s[j - 1] == 1) count++;
  18. if (count > x) x = count;//找到最长的1
  19. if (s[j] != s[j - 1]) count = 0;//置零
  20. }
  21. return x;
  22. }
  23. static void Main(string[] args) {
  24. string sb;
  25. while ((sb = Console.ReadLine()) != null) {
  26. string[] s = sb.Split();
  27. long a = long.Parse(s[0]), b = long.Parse(s[1]);
  28. if (f(a) > f(b)) Console.WriteLine("fat");
  29. else if (f(a) == f(b)) Console.WriteLine("fat and thin");
  30. else Console.WriteLine("thin");
  31. }
  32. }
  33. }
  34. }
  35. //找到最长的1

1193 小周的种田梦

1194 爱走楼梯的小胖

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1194 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int t = int.Parse(Console.ReadLine());
  9. while (t-- > 0) {
  10. string[] s = Console.ReadLine().Split();
  11. int n = int.Parse(s[0]), a = int.Parse(s[1]), b = int.Parse(s[2]);
  12. int[] ans = new int[105];
  13. string[] sb = Console.ReadLine().Split();
  14. for (int i = 1; i < n; i++)
  15. ans[i] = int.Parse(sb[i-1]);
  16. int sum = 0;
  17. if (a > b) { int temp = a; a = b; b = temp; }
  18. for (int i = a; i < b; i++)
  19. sum += ans[i];
  20. Console.WriteLine(sum);
  21. }
  22. }
  23. }
  24. }

1195 Good luck and have fun

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1195 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. int n = int.Parse(sb);
  11. while (n-- > 0) {
  12. string[] s = Console.ReadLine().Split();
  13. int y = int.Parse(s[0]), m = int.Parse(s[1]), d = int.Parse(s[2]);
  14. if (y == 2014 && m == 4 && d == 20) Console.WriteLine("nice day");
  15. else if (y < 2014 || (y == 2014 && m < 4) || (y == 2014 && m == 4 && d < 20))
  16. Console.WriteLine("before");
  17. else Console.WriteLine("after");
  18. }
  19. }
  20. }
  21. }
  22. }

1196 S1+S2

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1196 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s;
  9. while ((s = Console.ReadLine()) != null) {
  10. int n = int.Parse(s);
  11. while (n-- > 0) {
  12. string[] a = Console.ReadLine().Split();
  13. for (int i = 0; i < a.Length; i++)
  14. Console.Write(a[i]);
  15. Console.WriteLine();
  16. }
  17. }
  18. }
  19. }
  20. }

1197 曹冲称象

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1197 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int[] a = new int[4];
  12. for (int i = 0; i < 4; i++)
  13. a[i] = int.Parse(s[i]);
  14. Array.Sort(a, 0, 4);
  15. if (a[0] + a[1] + a[2] < 13)
  16. Console.WriteLine("good luck");
  17. else
  18. Console.WriteLine("oh no");
  19. }
  20. }
  21. }
  22. }

1198 排排队

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1198 {
  6. class Program {
  7. static long fun(long n) {
  8. long f;
  9. if (n == 2)
  10. f = 1;
  11. else if (n == 3)
  12. f = 2;
  13. else f = (n - 1) * (fun(n - 2) + fun(n - 1));
  14. return f;
  15. }
  16. static void Main(string[] args) {
  17. string sb;
  18. while ((sb = Console.ReadLine()) != null) {
  19. long n = long.Parse(sb);
  20. Console.WriteLine(fun(n));
  21. }
  22. }
  23. }
  24. }

1199 蛋疼的Plato

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1199 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. string[] s = sb.Split();
  11. int n = int.Parse(s[0]), k = int.Parse(s[1]);
  12. string[] b = Console.ReadLine().Split();
  13. int[] a = new int[10005];
  14. for (int i = 0; i < n; i++)
  15. a[i] = int.Parse(b[i]);
  16. Array.Sort(a, 0, n);
  17. Console.WriteLine(a[n - k]);
  18. }
  19. }
  20. }
  21. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注