[关闭]
@jtahstu 2015-09-07T12:22:49.000000Z 字数 36385 阅读 861

AKOJ Problem1000-1099 C#代码汇总

C# ACM Code


有代码的都是AC了的,没AC的只有个题目,以后假如AC了再把代码加上去

1000 A+B Problem

  1. using System;
  2. class Acm1000
  3. {
  4. static void Main()
  5. {
  6. string[] ss = Console.ReadLine().Split();
  7. Console.WriteLine(long.Parse(ss[0]) + long.Parse(ss[1]));
  8. }
  9. }

1001 ACM"水题"

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1001 {
  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. if (a == 0 && b == 0) break;
  13. long ans = (a + b) * (b - a + 1) / 2;
  14. Console.WriteLine(ans);
  15. }
  16. }
  17. }
  18. }

1002 手机靓号

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1002 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. int jtahstu = 0;
  10. while ((sb = Console.ReadLine()) != null) {
  11. int count = 0;
  12. for (int k = 0; k < 11; k++) {
  13. if (sb[k] == '6' || sb[k] == '8')
  14. count++;
  15. if (sb[k] == '4') { count = 0; break; }
  16. }
  17. if (count > 4) {
  18. Console.WriteLine(sb);
  19. jtahstu++;
  20. }
  21. }
  22. Console.WriteLine(jtahstu);
  23. //Console.ReadLine();
  24. }
  25. }
  26. }

1003 计算N!

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1003 {
  6. /// <summary>
  7. /// 大数阶乘
  8. /// 本代码参考老赵以前写过的大数阶乘代码
  9. /// </summary>
  10. class Program {
  11. static void Main(string[] args) {
  12. string sb;
  13. int i, j, temp, start, sc, N = 1200;
  14. while ((sb = Console.ReadLine()) != null) {
  15. int n = int.Parse(sb);
  16. int[] a = new int[N];
  17. for (a[0] = 1, i = 1; i <= n; i++)
  18. for (sc = 0, j = 0; j < N; j++) {
  19. temp = a[j] * i + sc;//当前这一位的数乘上i,然后加上后面来的进位
  20. sc = temp / 10;//sc代表进位
  21. a[j] = temp % 10;//本位保留模后的结果
  22. }
  23. //数据是倒着存的,即1*2*3*4=24,存是是按420000000...保存的,一直有N=1200位
  24. for (start = N - 1; a[start] == 0; --start) ;//这里是确定从后面哪一位开始输出,从后向前输出
  25. for (; start >= 0; --start)
  26. Console.Write(a[start]);
  27. Console.WriteLine();
  28. }
  29. }
  30. }
  31. }

1004 “顺”序列

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1004 {
  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().Split();
  11. int m = int.Parse(sb[0]);
  12. int[] a = new int[105];
  13. for (int i = 1; i <= m; i++)
  14. a[i] = int.Parse(sb[i]);
  15. Array.Sort(a, 1, m);
  16. int d = a[2] - a[1];
  17. bool flag = true;
  18. for (int i = 3; i <= m; i++)
  19. if (a[i] - a[i - 1] != d) {
  20. flag = false;
  21. Console.WriteLine("no");
  22. break;
  23. }
  24. if (flag)
  25. Console.WriteLine("yes");
  26. }
  27. }
  28. }
  29. }

1005 构造表达式

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1005 {
  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().Split();
  11. int a = int.Parse(sb[0]), b = int.Parse(sb[1]), c = int.Parse(sb[2]);
  12. int min = a;
  13. int max = a;
  14. if (b < min) min = b;
  15. if (b > max) max = b;
  16. if (max / min == c)
  17. Console.WriteLine("{0}/{1}={2}", max, min, c);
  18. else if (max - min == c)
  19. Console.WriteLine("{0}-{1}={2}", max, min, c);
  20. else if (max + min == c)
  21. Console.WriteLine("{0}+{1}={2}", max, min, c);
  22. else if (max * min == c)
  23. Console.WriteLine("{0}*{1}={2}", max, min, c);
  24. else
  25. Console.WriteLine("None");
  26. }
  27. }
  28. }
  29. }

1006 5个数求最值

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1006 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] s = Console.ReadLine().Split();
  9. int min = 10000000, max = -10000000;
  10. for (int i = 0; i < 5; i++) {
  11. int temp = int.Parse(s[i]);
  12. if (temp > max) max = temp;
  13. if (temp < min) min = temp;
  14. }
  15. Console.WriteLine("{0} {1}", min, max);
  16. }
  17. }
  18. }

1007 Fibonacci 数

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

1008 大小写互换

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1008 {
  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. for (int i = 0; i < s.Length; i++) {
  12. if (s[i] >= 'a' && s[i] <= 'z')
  13. Console.Write(s[i].ToString().ToUpper());
  14. else
  15. Console.Write(s[i].ToString().ToLower());
  16. }
  17. Console.WriteLine();
  18. }
  19. }
  20. }
  21. }

1009 公约数和公倍数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1009 {
  6. class Program {
  7. static int gcd(int a, int b) {
  8. return b == 0 ? a : gcd(b, a % b);
  9. }
  10. static int lcm(int a, int b) {
  11. return a / gcd(a, b) * b;
  12. }
  13. static void Main(string[] args) {
  14. int n = int.Parse(Console.ReadLine());
  15. while (n-- > 0) {
  16. string[] sb = Console.ReadLine().Split();
  17. int a = int.Parse(sb[0]), b = int.Parse(sb[1]);
  18. Console.WriteLine("{0} {1}", gcd(a, b), lcm(a, b));
  19. }
  20. }
  21. }
  22. }

1010 青蛙的约会

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1010 {
  6. /// <summary>
  7. /// 貌似叫扩展欧几里得定理,题目我都没看,代码已看不懂
  8. /// WA了,以后再来改吧
  9. /// </summary>
  10. class Program {
  11. static long x, y, m, n, l;
  12. static long ect_gcd(long a, long b, long x, long y) {
  13. long tmp, ret;
  14. if (b == 0) {
  15. x = 1; y = 0;
  16. return a;
  17. }
  18. ret = ect_gcd(b, a % b, x, y);
  19. tmp = x; x = y; y = tmp - a / b * y;
  20. return ret;
  21. }
  22. static void Main(string[] args) {
  23. string s;
  24. while ((s = Console.ReadLine()) != null) {
  25. string[] sb = s.Split();
  26. x = long.Parse(sb[0]); y = long.Parse(sb[1]); m = long.Parse(sb[2]); n = long.Parse(sb[3]); l = long.Parse(sb[4]);
  27. long a = n - m, b = l, c = x - y;
  28. long d = ect_gcd(a, b, x, y);
  29. if (c % d != 0) {
  30. Console.WriteLine("Impossible");
  31. continue;
  32. }
  33. x = (x * c / d) % (b / d);
  34. if (x < 0) x += b / d;
  35. Console.WriteLine(x);
  36. }
  37. }
  38. }
  39. }

1011 RLE解码

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

1012 机器指令

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1012 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s;
  9. string[] str = { "0000" , "0001" , "0010" , "0011" , "0100" , "0101" , "0110" , "0111" , "1000" , "1001" , "1010" , "1011" , "1100" , "1101" , "1110" , "1111" };
  10. while ((s = Console.ReadLine()) != null) {
  11. for (int i = 0 ; i < s.Length ; i++) {
  12. if (s[i] >= '0' && s[i] <= '9')
  13. Console.Write(str[s[i] - '0']);
  14. else
  15. Console.Write(str[s[i] - 'A' + 10]);
  16. }
  17. Console.WriteLine();
  18. }
  19. }
  20. }
  21. }
  22. //long n = Convert.ToInt64(s , 16);
  23. //string ans = Convert.ToString(n , 2);
  24. //Console.WriteLine(ans);

1013 分糖果

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1013 {
  6. class Program {
  7. static int gcd(int a, int b) {
  8. return b == 0 ? a : gcd(b, a % b);
  9. }
  10. static int lcm(int a, int b) {
  11. return a / gcd(a, b) * b;
  12. }
  13. static void Main(string[] args) {
  14. string s;
  15. while ((s = Console.ReadLine()) != null) {
  16. string[] a = s.Split();
  17. int a1 = int.Parse(a[0]), b1 = int.Parse(a[1]), a2 = int.Parse(a[2]), b2 = int.Parse(a[3]);
  18. for (int i = 1; i <= lcm(a1, a2); i++)//实际这样写我感觉是不合理的,但是AC了,怎么能求最小公倍数呢,i don't know!
  19. if (i % a1 == b1 && i % a2 == b2) { Console.WriteLine(i); break; }
  20. }
  21. }
  22. }
  23. }

1014 哥德巴赫猜想

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1014 {
  6. class Program {
  7. static bool prime(int n)//判断素数
  8. {
  9. if (n == 1) return false;
  10. if (n == 2) return true;
  11. for (int i = 2; i * i <= n; i++)
  12. if (n % i == 0) return false;
  13. return true;
  14. }
  15. static void Main(string[] args) {
  16. string sb;
  17. while ((sb = Console.ReadLine()) != null) {
  18. int n = int.Parse(sb);
  19. for (int i = n / 2; i > 0; i--) {
  20. if (prime(i) && prime(n - i)) {
  21. Console.WriteLine("{0} {1}", i, n - i);
  22. break;
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }

1015 最简单的编程语言

1016 连接电脑

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1016 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string jt;
  9. while ((jt = Console.ReadLine()) != null) {
  10. string[] s = jt.Split();
  11. int n = int.Parse(s[0]), m = int.Parse(s[1]);
  12. if (m + n == 0) break;
  13. if (m == 0 && n != 0) { Console.WriteLine(n - 1); continue; }
  14. string[] b = Console.ReadLine().Split();
  15. int[] a = new int[205];
  16. int count = 1;
  17. a[int.Parse(b[0])] = count;
  18. a[int.Parse(b[1])] = count;
  19. for (int i = 1; i < m; i++) {
  20. string[] sb = Console.ReadLine().Split();
  21. int p = int.Parse(sb[0]), q = int.Parse(sb[1]);
  22. if (a[p] != 0) a[q] = count;
  23. else if (a[q] != 0) a[p] = count;
  24. else {
  25. count++;
  26. a[p] = count;
  27. a[q] = a[p];
  28. }
  29. }
  30. for (int i = 1; i <= n; i++)
  31. if (a[i] == 0)
  32. count++;
  33. Console.WriteLine(count - 1);
  34. }
  35. }
  36. }
  37. }

1017 神奇的立方数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1017 {
  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. bool flag = false;
  12. for (int i = -1400; i <= 1400; i++) {
  13. if (i * i * i == n) {
  14. flag = true;
  15. break;
  16. }
  17. }
  18. if (flag)
  19. Console.WriteLine("YES");
  20. else
  21. Console.WriteLine("NO");
  22. //if (n < 0) n = -n;
  23. //int x = (int)Math.Pow(n, 1.0/3);
  24. ////x = Math.Floor(x);
  25. ////Console.WriteLine(x);
  26. //if (x * x * x == n)
  27. // Console.WriteLine("YES");
  28. //else
  29. // Console.WriteLine("NO");
  30. }
  31. }
  32. }
  33. }

1018 最长平台

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1018 {
  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[10005];
  12. string[] s = Console.ReadLine().Split();
  13. for (int i = 0; i < n; i++)
  14. a[i] = int.Parse(s[i]);
  15. int count = 1;
  16. for (int i = 1; i < n; i++) {
  17. if (a[i] == a[i - count])
  18. count++;
  19. }
  20. Console.WriteLine(count);
  21. }
  22. }
  23. }
  24. }

1019 还有多少桌面
1020 严格递增序列
1021 最后的胜利者
1022 快乐指数
1023 DNA Sorting

1024 A+B Problem

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1024 {
  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. if (a == 0 && b == 0) break;
  13. else Console.WriteLine(a + b);
  14. }
  15. }
  16. }
  17. }

1025 487-3279

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1025 {
  6. class Program {
  7. static string convert(string s) {
  8. string ans = "22233344455566670778889990";
  9. char[] ss = new char[50];
  10. int k = 0;
  11. for (int i = 0; i < s.Length; i++) {
  12. if (s[i] >= '0' && s[i] <= '9') { ss[k++] = s[i]; }
  13. if (s[i] >= 'A' && s[i] <= 'Z') { ss[k++] = ans[s[i] - 'A']; }
  14. }
  15. string st = new string(ss);
  16. return st.Substring(0, 3) + "-" + st.Substring(3, 4);
  17. }
  18. static void Main(string[] args) {
  19. int n = int.Parse(Console.ReadLine());
  20. string[] s = new string[n + 5];
  21. for (int i = 0; i < n; i++)
  22. s[i] = convert(Console.ReadLine());
  23. Array.Sort(s, 0, n);
  24. //for (int i = 0; i < n; i++)
  25. // Console.WriteLine(s[i]);
  26. int j = 0;
  27. string[] ans = new string[n];
  28. int[] an = new int[n];
  29. ans[0] = s[0];
  30. an[0] = 1;
  31. for (int i = 1; i < n; i++) {
  32. if (s[i] != s[i - 1]) {
  33. j++;
  34. ans[j] = s[i];
  35. an[j]++;
  36. } else {
  37. an[j]++;
  38. }
  39. }
  40. for (int i = 0; i < j; i++) {
  41. if (an[i] > 1) {
  42. Console.WriteLine(ans[i] + " " + an[i]);
  43. }
  44. }
  45. //Console.ReadLine();
  46. }
  47. }
  48. }

1026 被3、5整除的数

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

1027 Lucky Word

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1027 {
  6. class Program {
  7. static void Main(string[] args) {
  8. long n = long.Parse(Console.ReadLine());
  9. long sum = 0, temp = n;
  10. while (n > 0) {
  11. sum += n % 10;
  12. n /= 10;
  13. }
  14. if (temp % sum == 0)
  15. Console.WriteLine("Lucky Word");
  16. else
  17. Console.WriteLine("No Answer");
  18. }
  19. }
  20. }

1028 单词分隔

1029 括号配对问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1029 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. char[] stack = new char[10005];
  10. while (n-- > 0) {
  11. string s = Console.ReadLine();
  12. int i, l = s.Length, j = 0, flag = 1;
  13. for (i = 0; i < l; i++) {
  14. if (s[i] == '(' || s[i] == '[')
  15. stack[j++] = s[i];
  16. if (s[i] == ')') {
  17. if (stack[j - 1] == '(') {
  18. j--;
  19. flag = 1;
  20. } else
  21. flag = 0;
  22. }
  23. if (s[i] == ']') {
  24. if (stack[j - 1] == '[') {
  25. j--;
  26. flag = 1;
  27. } else
  28. flag = 0;
  29. }
  30. if (flag == 0) break;
  31. }
  32. if (flag == 1 && j == 0)
  33. Console.WriteLine("Yes");
  34. else
  35. Console.WriteLine("No");
  36. }
  37. }
  38. }
  39. }

1030 ASCII码排序

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1030 {
  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[0] + 'a'), (char)(a[1] + 'a'), (char)(a[2] + 'a'));
  16. }
  17. }
  18. }
  19. }

1031 素数求和问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1031 {
  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. int n = int.Parse(Console.ReadLine());
  17. while (n-- > 0) {
  18. int m = int.Parse(Console.ReadLine());
  19. string[] s = Console.ReadLine().Split();
  20. int sum = 0;
  21. for (int i = 0; i < m; i++)
  22. if (prime(int.Parse(s[i])))
  23. sum += int.Parse(s[i]);
  24. Console.WriteLine(sum);
  25. }
  26. //Console.ReadLine();
  27. }
  28. }
  29. }

1032 水仙花数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1032 {
  6. class Program {
  7. static bool jtahstu(int n) {
  8. int x = n % 10, y = n / 10 % 10, z = n / 100;
  9. if (x * x * x + y * y * y + z * z * z == n) return true;
  10. return false;
  11. }
  12. static void Main(string[] args) {
  13. string sb;
  14. while ((sb = Console.ReadLine()) != null) {
  15. int n = int.Parse(sb);
  16. if (n == 0) break;
  17. if (jtahstu(n))
  18. Console.WriteLine("Yes");
  19. else
  20. Console.WriteLine("No");
  21. }
  22. }
  23. }
  24. }

1033 鸡兔同笼

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1033 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int t = int.Parse(Console.ReadLine());
  9. while (t-- > 0) {
  10. string[] sb = Console.ReadLine().Split();
  11. int n = int.Parse(sb[0]), m = int.Parse(sb[1]);
  12. int x = 2 * n - m / 2, y = m / 2 - n;
  13. if (x + y == n && 2 * x + 4 * y == m && x >= 0 && y >= 0)
  14. Console.WriteLine("{0} {1}", x, y);
  15. else
  16. Console.WriteLine("No answer");
  17. }
  18. }
  19. }
  20. }

1034 梯形

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1034 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. double x = double.Parse(sb[0]), y = double.Parse(sb[1]), z = double.Parse(sb[2]);
  10. double area = (x + y) * z / 2;
  11. double perimeter = x + y + Math.Sqrt(4 * z * z + (y - x) * (y - x));
  12. Console.WriteLine(area.ToString("0.00"));
  13. Console.WriteLine(perimeter.ToString("0.00"));
  14. }
  15. }
  16. }

1035 回声壁

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

1036 中文系素素的困惑

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1036 {
  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[32];
  12. int i = 0;
  13. while (m > 0) {
  14. a[i] = m % 2;
  15. m /= 2;
  16. i++;
  17. }
  18. for (int j = 31; j >= 0; j--)
  19. Console.Write(a[j]);
  20. Console.WriteLine();
  21. }
  22. }
  23. }
  24. }

1037 八皇后问题

1038 不吉利的数字

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1038 {
  6. class Program {
  7. static bool judge(int n)//判断数字是否包含0
  8. {
  9. if (n == 0) return true;
  10. while (n > 0) {
  11. if (n % 10 == 0) return true;
  12. n /= 10;
  13. }
  14. return false;
  15. }
  16. static int fuck(int n)//十进制转九进制
  17. {
  18. int sum = 0, i = 1;
  19. while (n > 0) {
  20. sum = sum + n % 10 * i;
  21. n /= 10;
  22. i *= 9;
  23. }
  24. return sum;
  25. }
  26. static void Main(string[] args) {
  27. string sb;
  28. while ((sb = Console.ReadLine()) != null) {
  29. int n = int.Parse(sb);
  30. if (judge(n))
  31. Console.WriteLine("Unlucky");
  32. else
  33. Console.WriteLine(fuck(n));
  34. }
  35. }
  36. }
  37. }

1039 单目标0/1背包问题
1040 用动态规划求解矩阵乘法链问题

1041 找零钱

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1041 {
  6. /// <summary>
  7. /// 哈哈,这个方法就问你6不6
  8. /// </summary>
  9. class Program {
  10. static void Main(string[] args) {
  11. int n = int.Parse(Console.ReadLine());
  12. int x1, x2, x3, x4, x5, x6, x7;
  13. x1 = n / 100;
  14. n = n % 100;
  15. x2 = n / 50;
  16. n = n % 50;
  17. x3 = n / 20;
  18. n = n % 20;
  19. x4 = n / 10;
  20. n = n % 10;
  21. x5 = n / 5;
  22. n = n % 5;
  23. x6 = n / 2;
  24. n = n % 2;
  25. x7 = n;
  26. for (int i = 0; i < x1; i++)
  27. Console.WriteLine("100");
  28. for (int i = 0; i < x2; i++)
  29. Console.WriteLine("50");
  30. for (int i = 0; i < x3; i++)
  31. Console.WriteLine("20");
  32. for (int i = 0; i < x4; i++)
  33. Console.WriteLine("10");
  34. for (int i = 0; i < x5; i++)
  35. Console.WriteLine("5");
  36. for (int i = 0; i < x6; i++)
  37. Console.WriteLine("2");
  38. for (int i = 0; i < x7; i++)
  39. Console.WriteLine("1");
  40. }
  41. }
  42. }

1042 二进制计算

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1042 {
  6. class Program {
  7. static long f(long a)//2进制转换成10进制
  8. {
  9. long s = 0, j = 1;
  10. while (a > 0) {
  11. s += (a % 10) * j;
  12. a = a / 10;
  13. j = j * 2;
  14. }
  15. return s;
  16. }
  17. static long g(long s)//10进制转换成2进制
  18. {
  19. long j = 1, n = 0;
  20. while (s > 0) {
  21. n += (s % 2) * j;
  22. s = s / 2;
  23. j *= 10;
  24. }
  25. return n;
  26. }
  27. static void Main(string[] args) {
  28. string sb;
  29. while ((sb = Console.ReadLine()) != null) {
  30. string[] s = sb.Split();
  31. long a = long.Parse(s[0]), b = long.Parse(s[2]);
  32. if (s[1] == "+")
  33. Console.WriteLine(g(f(a) + f(b)));
  34. else
  35. Console.WriteLine(g(f(a) - f(b)));
  36. }
  37. }
  38. }
  39. }

1043 n个人的工作分配
1044 用分枝定界法求解TSP问题

1045 删除重复

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

1046 单词统计问题

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1046 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s = Console.ReadLine();
  9. string[] ss = s.Split();
  10. Console.WriteLine(ss.Length);
  11. Array.Sort(ss, 0, ss.Length);
  12. int j = 0;
  13. string[] ans = new string[ss.Length];
  14. int[] an = new int[ss.Length];
  15. ans[0] = ss[0];
  16. an[0] = 1;
  17. for (int i = 1; i < ss.Length; i++) {
  18. if (ss[i] != ss[i - 1]) {
  19. j++;
  20. ans[j] = ss[i];
  21. an[j]++;
  22. } else {
  23. an[j]++;
  24. }
  25. }
  26. for (int i = 0; i <= j; i++)
  27. Console.WriteLine(ans[i] + ":" + an[i]);
  28. //Console.ReadLine();
  29. }
  30. }
  31. }

1047 排序

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

1048 求某一整数序列的全排列问题

1049 矩阵翻转

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1049 {
  6. class Program {
  7. static int[,] a = new int[101, 101];
  8. static void f(int n)//翻转90度
  9. {
  10. for (int j = n - 1; j >= 0; j--) {
  11. for (int i = 0; i < n; i++) {
  12. Console.Write("{0} ", a[i, j]);
  13. }
  14. Console.WriteLine();
  15. }
  16. }
  17. static void g(int n)//翻转180度
  18. {
  19. for (int i = n - 1; i >= 0; i--) {
  20. for (int j = n - 1; j >= 0; j--) {
  21. Console.Write("{0} ", a[i, j]);
  22. }
  23. Console.WriteLine();
  24. }
  25. }
  26. static void h(int n)//翻转270度
  27. {
  28. for (int i = 0; i < n; i++) {
  29. for (int j = n - 1; j >= 0; j--) {
  30. Console.Write("{0} ", a[j, i]);
  31. }
  32. Console.WriteLine();
  33. }
  34. }
  35. static void Main(string[] args) {
  36. int n = int.Parse(Console.ReadLine());
  37. int m = int.Parse(Console.ReadLine());
  38. for (int i = 0; i < n; i++) {
  39. string[] s = Console.ReadLine().Split();
  40. for (int j = 0; j < n; j++) {
  41. a[i, j] = int.Parse(s[j]);
  42. }
  43. }
  44. if (m == 1)
  45. f(n);
  46. if (m == 2)
  47. g(n);
  48. if (m == 3)
  49. h(n);
  50. //Console.ReadLine();
  51. }
  52. }
  53. }

1050 C语言合法标识符

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1050 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. while (n-- > 0) {
  10. string str = Console.ReadLine();
  11. int s = 0, s1 = 0;
  12. for (int i = 0; i < str.Length; i++) {
  13. if (str[i] == '_') s++;
  14. if (str[i] >= '0' && str[i] <= '9' && i != 0 || str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z')
  15. s1++;
  16. }
  17. if (s + s1 == str.Length)
  18. Console.WriteLine("yes");
  19. else
  20. Console.WriteLine("no");
  21. }
  22. }
  23. }
  24. }

1051 首字母变大写

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

1052 字符串统计

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1052 {
  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] >= '0' && sb[i] <= '9')
  14. count++;
  15. Console.WriteLine(count);
  16. }
  17. }
  18. }
  19. }

1053 大数阶乘

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1053 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. int i, j, temp, start, sc, N = 1200;
  10. while ((sb = Console.ReadLine()) != null) {
  11. int n = int.Parse(sb);
  12. int[] a = new int[N];
  13. for (a[0] = 1, i = 1; i <= n; i++)
  14. for (sc = 0, j = 0; j < N; j++) {
  15. temp = a[j] * i + sc;//当前这一位的数乘上i,然后加上后面来的进位
  16. sc = temp / 10;//sc代表进位
  17. a[j] = temp % 10;//本位保留模后的结果
  18. }
  19. //数据是倒着存的,即1*2*3*4=24,存是是按420000000...保存的,一直有N=1200位
  20. for (start = N - 1; a[start] == 0; --start) ;//这里是确定从后面哪一位开始输出,从后向前输出
  21. for (; start >= 0; --start)
  22. Console.Write(a[start]);
  23. Console.WriteLine();
  24. }
  25. }
  26. }
  27. }

1054 求逆序数
1055 矩阵乘法

1056 三点顺序

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

1057 评委打分

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1057 {
  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. double max = -100000000, min = 10000000, sum = 0;
  13. for (int i = 1; i <= n; i++) {
  14. sum += double.Parse(s[i]);
  15. if (double.Parse(s[i]) > max) max = double.Parse(s[i]);
  16. if (double.Parse(s[i]) < min) min = double.Parse(s[i]);
  17. }
  18. double average = (sum - max - min) / (n - 2);
  19. Console.WriteLine(average.ToString("0.00"));
  20. }
  21. }
  22. }
  23. }

1058 货币兑换

1059 Picture

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1059 {
  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. Console.Write("+");//第一行
  13. for (int i = 0; i < n; i++)
  14. Console.Write("-");
  15. Console.WriteLine("+");
  16. for (int i = 0; i < m; i++)//中间的|和空格
  17. {
  18. Console.Write("|");
  19. for (int j = 0; j < n; j++)
  20. Console.Write(" ");
  21. Console.WriteLine("|");
  22. }
  23. Console.Write("+");//最后一行,和第一行一样
  24. for (int i = 0; i < n; i++)
  25. Console.Write("-");
  26. Console.WriteLine("+");
  27. Console.WriteLine();
  28. }
  29. }
  30. }
  31. }

1060 取个标题好难

1061 最小公倍数

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

1062 最左边一位数

1063 发奖学金咯^_^

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1063 {
  6. class Program {
  7. static int f(int n)//该函数由Problem_1041改编而来
  8. {
  9. int[] b = { 100, 50, 10, 5, 2, 1 }; //开数组,储存币种
  10. int kk;
  11. int count = 0;
  12. for (int i = 0; i < 6; i++) {
  13. kk = n / b[i];//除即可得kk张面值为a[i]的零钱
  14. n %= b[i];
  15. count += kk;
  16. }
  17. return count;
  18. }
  19. static void Main(string[] args) {
  20. string sb;
  21. while ((sb = Console.ReadLine()) != null) {
  22. int n = int.Parse(sb);
  23. if (n == 0) break;
  24. string[] s = Console.ReadLine().Split();
  25. int sum = 0;
  26. for (int i = 0; i < n; i++) {
  27. int x = int.Parse(s[i]);
  28. sum += f(x);
  29. }
  30. Console.WriteLine(sum);
  31. }
  32. }
  33. }
  34. }

1064 A+B(1)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1064 {
  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 x = int.Parse(s[0]), y = int.Parse(s[1]);
  12. Console.WriteLine(x + y);
  13. }
  14. }
  15. }
  16. }

1065 A+B(2)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1065 {
  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().Split();
  11. int x = int.Parse(sb[0]), y = int.Parse(sb[1]);
  12. Console.WriteLine(x + y);
  13. }
  14. }
  15. }
  16. }

1066 A+B(3)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1066 {
  6. /// <summary>
  7. /// 表示这条道题我很郁闷,又是一直RE
  8. /// what's a fuck
  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. int n = int.Parse(s[0]);
  16. if (n == 0) break;
  17. int sum = 0;
  18. for (int i = 1; i <= n; i++)
  19. sum += int.Parse(s[i]);
  20. Console.WriteLine(sum);
  21. }
  22. }
  23. }
  24. }

1067 A+B(4)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1067 {
  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 x = int.Parse(s[0]), y = int.Parse(s[1]);
  12. if (x == 0 && y == 0) break;
  13. Console.WriteLine(x + y);
  14. }
  15. }
  16. }
  17. }

1068 A+B(5)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1068 {
  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 t = int.Parse(s[0]);
  12. int sum = 0, i = 1;
  13. while (t-- > 0) {
  14. sum += int.Parse(s[i]);
  15. i++;
  16. }
  17. Console.WriteLine(sum);
  18. }
  19. }
  20. }
  21. }

1069 A+B(6)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1069 {
  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 sum = 0, i = 1;
  14. while (n-- > 0) {
  15. sum += int.Parse(s[i]);
  16. i++;
  17. }
  18. Console.WriteLine(sum);
  19. }
  20. }
  21. }
  22. }

1070 A+B(7)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1070 {
  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 x = int.Parse(s[0]), y = int.Parse(s[1]);
  12. Console.WriteLine(x + y);
  13. Console.WriteLine();
  14. }
  15. }
  16. }
  17. }

1071 A+B(8)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1071 {
  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 t = int.Parse(s[0]);
  12. int sum = 0, i = 1;
  13. while (t-- > 0) {
  14. sum += int.Parse(s[i]);
  15. i++;
  16. }
  17. Console.WriteLine(sum);
  18. Console.WriteLine();
  19. }
  20. }
  21. }
  22. }

1072 Sum Problem

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1072 {
  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 sum = (1 + n) * n / 2;
  12. Console.WriteLine(sum);
  13. }
  14. }
  15. }
  16. }

1073 Let the Balloon Rise

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1073 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sn;
  9. while (!(sn = Console.ReadLine()).Equals("0")) {
  10. int n = int.Parse(sn);
  11. string[] s = new string[n + 5];
  12. for (int i = 0 ; i < n ; i++)
  13. s[i] = Console.ReadLine();
  14. string axb = s[0];
  15. Array.Sort(s , 0 , n);
  16. int max = 1;
  17. int count = 1;
  18. int flag = 0;
  19. for (int i = 0 ; i < n ; i++) {
  20. count = 1;
  21. for (int j = i + 1 ; j < n ; j++) {
  22. if (s[j].Equals(s[i]))
  23. count++;
  24. else
  25. break;
  26. }
  27. if (count > max) {
  28. max = count;
  29. flag = i;
  30. }
  31. }
  32. if (max == 1)//??????????????????????????????????????????????????????????????
  33. Console.WriteLine(axb);
  34. else
  35. Console.WriteLine(s[flag]);
  36. }
  37. }
  38. }
  39. }

1074 人见人爱A^B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1074 {
  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. int ans = 1;
  14. for (int i = 1; i <= m; i++) {
  15. ans *= n;
  16. ans %= 1000;
  17. }
  18. Console.WriteLine(ans);
  19. }
  20. }
  21. }
  22. }

1075 第几天?

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1075 {
  6. class Program {
  7. static bool leapyear(int n) {
  8. if ((n % 4 == 0 && n % 100 != 0) || n % 400 == 0)
  9. return true;
  10. return false;
  11. }
  12. static void Main(string[] args) {
  13. string sb;
  14. while ((sb = Console.ReadLine()) != null) {
  15. int x = 0, y = 0;//前面这一大串就是要解决输入问题,真尼玛坑
  16. for (int i = 0; i < sb.Length; i++) {
  17. if (sb[i] == '/' && x == 0)
  18. x = i;
  19. if (sb[i] == '/' && x != 0)
  20. y = i;
  21. }
  22. int year = int.Parse(sb.Substring(0, x));
  23. int month = int.Parse(sb.Substring(x + 1, y - x - 1));
  24. int day = int.Parse(sb.Substring(y + 1, sb.Length - y - 1));
  25. //Console.WriteLine(year + " " + month + " " + day);
  26. int[] a = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//非闰年
  27. int[] b = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//闰年
  28. int sum = 0;
  29. if (leapyear(year)) {
  30. for (int i = 0; i < month - 1; i++)
  31. sum += b[i];
  32. sum += day;
  33. } else {
  34. for (int i = 0; i < month - 1; i++)
  35. sum += a[i];
  36. sum += day;
  37. }
  38. Console.WriteLine(sum);
  39. }
  40. }
  41. }
  42. }

1076 Encoding

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

1077 The 3n + 1 problem

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1077 {
  6. /// <summary>
  7. /// 找一个范围内转换次数最多的次数输出
  8. /// </summary>
  9. class Program {
  10. static int tsy(int a) {
  11. int count = 1;
  12. while (a != 1) {
  13. if (a % 2 == 1) { a = 3 * a + 1; count++; } else { a /= 2; count++; }
  14. }
  15. return count;
  16. }
  17. static void Main(string[] args) {
  18. string sb;
  19. while ((sb = Console.ReadLine()) != null) {
  20. string[] s = sb.Split();
  21. int n = int.Parse(s[0]), m = int.Parse(s[1]);
  22. int n1 = n, m1 = m;
  23. if (n > m) {
  24. int temp = m;
  25. m = n;
  26. n = temp;
  27. }
  28. int max = -1;
  29. for (int i = n; i <= m; i++) {
  30. int count = tsy(i);
  31. if (count > max) max = count;
  32. }
  33. Console.WriteLine("{0} {1} {2}", n1, m1, max);
  34. }
  35. }
  36. }
  37. }

1078 n-1位数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1078 {
  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 ans = int.Parse(sb) - (int)Math.Pow(10.0, sb.Length - 1) * (sb[0] - '0');
  12. Console.WriteLine(ans);
  13. }
  14. }
  15. }
  16. }

1079 周期串

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1079 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s;
  9. while ((s = Console.ReadLine()) != null) {
  10. int t = 0;
  11. bool falg = true;
  12. for (int i = 1; i <= s.Length; i++) {
  13. if (s.Length % i == 0 && falg) {
  14. string sb = s.Substring(0, i);
  15. int j = 0;
  16. for (j = i; j < s.Length; j += i) {
  17. string temp = s.Substring(j, i);
  18. if (temp != sb) {
  19. break;
  20. }
  21. }
  22. if (j == s.Length) { t = i; falg = false; break; }
  23. }
  24. }
  25. Console.WriteLine(t);
  26. }
  27. }
  28. }
  29. }

1080 奇数检测

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1080 {
  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]);
  12. int[] a = new int[10001];
  13. for (int i = 1; i <= n; i++)
  14. a[int.Parse(s[i])]++;
  15. for (int i = 0; i < 10001; i++)
  16. if (a[i] != 0 && a[i] % 2 == 1) {
  17. Console.WriteLine(i);
  18. break;
  19. }
  20. }
  21. }
  22. }
  23. }

1081 小明A+B(2)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1081 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string s = Console.ReadLine();
  9. string b = Console.ReadLine();
  10. int x = int.Parse(Console.ReadLine());
  11. int n = (s[s.Length - 1] - '0') + (b[b.Length - 1] - '0');
  12. if (n % 10 == x)
  13. Console.WriteLine("YES");
  14. else
  15. Console.WriteLine("NO");
  16. //Console.ReadLine();
  17. }
  18. }
  19. }

1082 螺旋矩阵

1083 分!分!分! 学生的命根
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. namespace AK1083 {
  7. class Program {
  8. struct people {
  9. public string name;
  10. public double yin, zheng, shu, zhuan;
  11. public double zong;
  12. public double chu;
  13. public double fu;
  14. };
  15. public class MyComparer : IComparer<people> {
  16. int IComparer<people>.Compare(people x, people y) {
  17. if (x.zong == y.zong) {
  18. return x.name.CompareTo(y.name);
  19. }
  20. return x.zong < y.zong ? 1 : -1;
  21. }
  22. }
  23. static void Main(string[] args) {
  24. string[] s = Console.ReadLine().Split();
  25. double[] a = new double[5 + 2];
  26. for (int i = 0; i < 5; i++)
  27. a[i] = double.Parse(s[i]);
  28. string str;
  29. people[] sql = new people[205];
  30. int j = 0;
  31. while ((str = Console.ReadLine()) != null) {
  32. string[] ss = Regex.Split(str, @"\s+");
  33. sql[j].name = ss[0];
  34. sql[j].yin = double.Parse(ss[1]);
  35. sql[j].zheng = double.Parse(ss[2]);
  36. sql[j].shu = double.Parse(ss[3]);
  37. sql[j].zhuan = double.Parse(ss[4]);
  38. sql[j].chu = sql[j].yin + sql[j].zheng + sql[j].shu + sql[j].zhuan;
  39. sql[j].fu = double.Parse(ss[5]);
  40. sql[j].zong = sql[j].chu * 0.6 + sql[j].fu * 0.4;
  41. j++;
  42. }
  43. Array.Sort(sql, 0, j, new MyComparer());
  44. int rank = 1;
  45. for (int i = 0; i < j; i++) {
  46. if (sql[i].chu >= a[4] && sql[i].yin >= a[0] && sql[i].zheng >= a[1] && sql[i].shu >= a[2] && sql[i].zhuan >= a[3] && sql[i].fu >= 60)
  47. Console.WriteLine("{0} {1} {2} {3} {4}", sql[i].name, sql[i].chu, sql[i].fu, sql[i].zong.ToString("0.0"), rank++);
  48. }
  49. Console.ReadLine();
  50. }
  51. }
  52. }

1084 找子串

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

1085 判断奇偶性

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1085 {
  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 count = 0;
  12. while (n > 0) {
  13. count += n % 2;
  14. n = n >> 1;
  15. }
  16. if (count % 2 == 0)
  17. Console.WriteLine("even");
  18. else
  19. Console.WriteLine("odd");
  20. }
  21. }
  22. }
  23. }

1086 逆转一个数中的位

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1086 {
  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 i = 1, ans = 0;
  12. while (n > 0) {
  13. long temp = n % 2;
  14. ans = ans * 2 + temp;//摸出来的一次*2即可
  15. n = n / 2;
  16. }
  17. Console.WriteLine(ans);
  18. }
  19. }
  20. }
  21. }

1087 图书馆占位

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1087 {
  6. class Program {
  7. struct Time {
  8. public int start;
  9. public int end;
  10. }
  11. public class MyComparer : IComparer<Time> {
  12. int IComparer<Time>.Compare(Time a , Time b) {
  13. return a.end < b.end ? -1 : 1;
  14. }
  15. }
  16. static void Main(string[] args) {
  17. string s;
  18. while ((s = Console.ReadLine()) != null) {
  19. int n = int.Parse(s);
  20. Time[] a = new Time[n + 5];
  21. for (int i = 0 ; i < n ; i++) {
  22. string[] ss = Console.ReadLine().Split();
  23. a[i].start = int.Parse(ss[0]);
  24. a[i].end = int.Parse(ss[1]);
  25. }
  26. Array.Sort(a , 0 , n , new MyComparer());
  27. int count = 1 , temp = a[0].end;
  28. for (int i = 1 ; i < n ; i++) {
  29. if (a[i].start >= temp) {
  30. count++;
  31. temp = a[i].end;
  32. }
  33. }
  34. Console.WriteLine(count);
  35. }
  36. }
  37. }
  38. }

1088 输出二叉树

1089 寻找幸运数

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

1090 简单编码

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1090 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string sb;
  9. while ((sb = Console.ReadLine()) != null) {
  10. if (sb.Equals("END")) break;
  11. for (int i = 0; i < sb.Length; i++) {
  12. if (sb[i] == 'A' || sb[i] == 'W' || sb[i] == 'F') Console.Write("I");
  13. else if (sb[i] == 'C') Console.Write("L");
  14. else if (sb[i] == 'M') Console.Write("o");
  15. else if (sb[i] == 'S') Console.Write("v");
  16. else if (sb[i] == 'D' || sb[i] == 'P' || sb[i] == 'G' || sb[i] == 'B') Console.Write("e");
  17. else if (sb[i] == 'L') Console.Write("Y");
  18. else if (sb[i] == 'X') Console.Write("u");
  19. else Console.Write(sb[i]);
  20. }
  21. Console.WriteLine();
  22. }
  23. }
  24. }
  25. }

1091 逆反A*B

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

1092 整数变换问题

1093 一种排序

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK093 {
  6. class Program {
  7. struct Rectangle {
  8. public int len , wid , bian;
  9. }
  10. public class MyComparer : IComparer<Rectangle> {
  11. int IComparer<Rectangle>.Compare(Rectangle x , Rectangle y) {
  12. if (x.bian == y.bian) {
  13. if (x.len == y.len)
  14. return x.wid < y.wid ? -1 : 1;
  15. return x.len < y.len ? -1 : 1;
  16. }
  17. return x.bian < y.bian ? -1 : 1;
  18. }
  19. }
  20. static void Main(string[] args) {
  21. int n = int.Parse(Console.ReadLine());
  22. while (n-- > 0) {
  23. int m = int.Parse(Console.ReadLine());
  24. Rectangle[] a = new Rectangle[m + 5];
  25. for (int i = 0 ; i < m ; i++) {
  26. string[] te = Console.ReadLine().Split();
  27. a[i].bian = int.Parse(te[0]);
  28. a[i].len = Math.Max(int.Parse(te[1]) , int.Parse(te[2]));
  29. a[i].wid = Math.Min(int.Parse(te[1]) , int.Parse(te[2]));
  30. }
  31. Array.Sort(a , 0 , m , new MyComparer());
  32. Console.WriteLine(a[0].bian + " " + a[0].len + " " + a[0].wid);
  33. for (int i = 1 ; i < m ; i++) {
  34. if (a[i].len == a[i - 1].len && a[i].wid == a[i - 1].wid && a[i].bian == a[i - 1].bian)
  35. continue;
  36. Console.WriteLine(a[i].bian + " " + a[i].len + " " + a[i].wid);
  37. }
  38. }
  39. }
  40. }
  41. }

1094 圆柱体的表面积

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1094 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. double r = double.Parse(sb[0]), h = double.Parse(sb[1]);
  10. double area = (2 * r * r + 2 * r * h) * Math.PI;
  11. Console.Write("Area=");
  12. Console.WriteLine(area.ToString("0.000"));
  13. }
  14. }
  15. }

1095 三位数反转

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1095 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int n = int.Parse(Console.ReadLine());
  9. Console.WriteLine(n % 10 * 100 + n / 10 % 10 * 10 + n / 100);
  10. }
  11. }
  12. }

1096 变量交换

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1096 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. Console.WriteLine("{0} {1}", sb[1], sb[0]);
  10. }
  11. }
  12. }

1097 三整数排序

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1097 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. int[] a = new int[3];
  10. a[0] = int.Parse(sb[0]); a[1] = int.Parse(sb[1]); a[2] = int.Parse(sb[2]);
  11. Array.Sort(a);
  12. Console.WriteLine("{0} {1} {2}", a[0], a[1], a[2]);
  13. }
  14. }
  15. }

1098 计算平均数

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1098 {
  6. class Program {
  7. static void Main(string[] args) {
  8. string[] sb = Console.ReadLine().Split();
  9. double x = double.Parse(sb[0]), y = double.Parse(sb[1]), z = double.Parse(sb[2]);
  10. Console.WriteLine(((x + y + z) / 3).ToString("0.000"));
  11. }
  12. }
  13. }

1099 温度转化

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace AK1099 {
  6. class Program {
  7. static void Main(string[] args) {
  8. int f = int.Parse(Console.ReadLine());
  9. double c = 5.0 * (f - 32) / 9;
  10. Console.WriteLine(c.ToString("0.000"));
  11. }
  12. }
  13. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注