校ACM第三次次预选赛 - 总结
总结
第三次预选赛面向的是专科的同学, 题目难度相对上两场会容易的多, 但是也有比较难的题目. 比赛共274人参加, 共3362次提交, 595次AC
-----------------------下面是题解----------------------------------------
A 伟大的征途
//直接输出并换行即可, 记得换行!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
}
B 闰年
//输入一个年份, 判断是不是闰年即可
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int year;
year=int.Parse(Console.ReadLine());
if(year%4==0&&year%100!=0||year%400==0)
Console.WriteLine("leap year");
else
Console.WriteLine("not leap year");
}
}
}
C 帮帮老师1
只涉及基本的选择判断, 按照题意选择即可
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int score;
score=int.Parse(Console.ReadLine());
if(score>=0&&score<=100)
{
switch(score/10)
{
case 10 :
case 9: Console.WriteLine("A");break;
case 8: Console.WriteLine("B"); break;
case 7: Console.WriteLine("C"); break;
case 6: Console.WriteLine("D"); break;
default:Console.WriteLine("E");break;
}
}
}
}
}
帮帮老师2
只涉及基本的选择判断和循环输入, 然后求平均数即可
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int n, m;
string str = Console.ReadLine();
string[] str_nm = str.Split(' ');
n = int.Parse(str_nm[0]);
m = int.Parse(str_nm[1]);
string Read_n = Console.ReadLine();
string Read_m = Console.ReadLine();
float k,avg_n=0,avg_m=0;
string[] str_n = new string[n];
str_n = Read_n.Split(' ');
string[] str_m = Read_m.Split(' ');
float[] arr_n = new float[str_n.Length];
for (int i = 0; i < str_n.Length; i++)
{
k = float.Parse(str_n[i]);
if(k>=0&&k<=100)
arr_n[i] = k;
}
float[] arr_m = new float[str_m.Length];
for (int i = 0; i < str_m.Length; i++)
{
k = float.Parse(str_m[i]);
if (k >= 0 && k <= 100)
arr_m[i] = k;
}
for (int i = 0; i < n; i++)
avg_n += arr_n[i];
for (int i = 0; i < m; i++)
avg_m += arr_m[i];
Console.WriteLine("{0,2:f} {1,2:f}", avg_n / n, avg_m / m);
}
}
}
E 斐波那契
这道题目是本次赛组中比较难的一道题目, 递推公式已经给出并不困难, 主要是考虑到数据溢出的情况, 所以取余的话要分别把两个加数都取余
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n;
int[] fn = new int[1000000];
n = int.Parse(Console.ReadLine());
if (n >= 1 && n <= 1000000)
{
fn[0] = 1; fn[1] = 1;
for (int i = 2; i < n; i++)
fn[i] = (fn[i - 1] % 10007 + fn[i - 2] % 10007) % 10007;
Console.WriteLine(fn[n - 1]);
}
}
}
}
F yy的病
首先就是一个循环找出所有%7==0或是位数里带7的数并记录下来, 最后平方求和即可
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int n;
int i;
while (int.TryParse(Console.ReadLine(),out n))
{
int sum = 0;
for (i = 0; i <=n; i++)
{
if (i % 7 == 0 || i % 10 == 7 || i / 10 == 7)
continue;
else
sum = sum + i * i;
}
Console.WriteLine(sum);
}
}
}
}