博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OUC_Summer Training_ DIV2_#5
阅读量:4510 次
发布时间:2019-06-08

本文共 14094 字,大约阅读时间需要 46 分钟。

这是做的最好的一次了一共做了4道题  嘻嘻~
A - Game Outcome
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winningif the sum of the column numbers is strictly greater than the sum of the row numbers.

 

 

For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.

Input

The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.

Output

Print the single number — the number of the winning squares.

Sample Input

Input
1 1
Output
0
Input
2 1 2 3 4
Output
2
Input
4 5 7 8 4 9 5 3 2 1 6 6 4 9 5 7 3
Output
6

Hint

In the first example two upper squares are winning.

In the third example three left squares in the both middle rows are winning:

5 7 8 4 9 5 3 2 1 6 6 4 9 5 7 3

 题目的意思大概是以一个格子为准列和大于行和的总数  暴力写的

1 #include
2 int a[32][32]; 3 int main() 4 { 5 int n,i,j,k,sum1 = 0,sum2 = 0,m = 0; 6 scanf("%d",&n); 7 for(i = 0;i < n;i++) 8 { 9 for(j = 0;j < n;j++)10 scanf("%d",&a[i][j]);11 }12 for(i = 0;i < n;i++)13 {14 for(j = 0;j < n;j++)15 {16 for(k = 0;k < n;k++)17 {18 sum1 += a[i][k];19 sum2 += a[k][j];20 }21 if(sum1 < sum2)m++;22 sum1 = 0;23 sum2 = 0;24 }25 26 }27 printf("%d",m);28 return 0;29 }
View Code
B - Trace
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. Some parts were painted red and all the other were painted blue. Besides, any two neighboring parts were painted different colors, that is, the red and the blue color were alternating, i. e. followed one after the other. The outer area of the wall (the area that lied outside all circles) was painted blue. Help Sherlock Holmes determine the total area of red parts of the wall.

Let us remind you that two circles are called concentric if their centers coincide. Several circles are called concentric if any two of them are concentric.

Input

The first line contains the single integer n (1 ≤ n ≤ 100). The second line contains n space-separated integers ri (1 ≤ ri ≤ 1000) — the circles' radii. It is guaranteed that all circles are different.

Output

Print the single real number — total area of the part of the wall that is painted red. The answer is accepted if absolute or relative error doesn't exceed 10 - 4.

Sample Input

Input
1 1
Output
3.141592653589793
Input
3 1 4 2
Output
40.840704496667314

Hint

In the first sample the picture is just one circle of radius 1. Inner part of the circle is painted red. The area of the red part equals π × 12 = π.

In the second sample there are three circles of radii 14 and 2. Outside part of the second circle is painted blue. Part between the second and the third circles is painted red. Part between the first and the third is painted blue. And, finally, the inner part of the first circle is painted red. Overall there are two red parts: the ring between the second and the third circles and the inner part of the first circle. Total area of the red parts is equal (π × 42 - π × 22) + π × 12 = π × 12 + π = 13π

 

题目的意思大概是 有好几个同心圆 分别给出半径 给同心圆涂颜色 最外面的区域是蓝色的 整个平面的颜色是蓝红相间的求红色区域的面积

没什么好说的,直接做就好了。

1 #include
2 using namespace std; 3 #include
4 #include
5 #define PI acos(-1.0) 6 int a[110]; 7 int main() 8 { 9 int n,i,j = 1,sum = 0;10 double s;11 cin >> n;12 for(i = 0;i < n;i++)13 cin >> a[i];14 sort(a,a+n);15 for(i = n-1;i >= 0;i-- )16 {17 if(j == 1)18 {19 sum += a[i] * a[i];20 j = 0;21 }22 else if(j == 0)23 {24 sum -= a[i] * a[i];25 j = 1;26 }27 }28 s = sum * PI;29 cout << s;30 return 0;31 }
View Code

 

 

D - Wasted Time
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing papers.

Mr. Scrooge's signature can be represented as a polyline A1A2... An. Scrooge signs like that: first it places a pen at the point A1, then draws a segment from point A1 to point A2, then he draws a segment from point A2 to point A3 and so on to point An, where he stops signing and takes the pen off the paper. At that the resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style. As Scrooge makes the signature, he never takes the pen off the paper and his writing speed is constant — 50 millimeters per second.

Scrooge signed exactly k papers throughout his life and all those signatures look the same.

Find the total time Scrooge wasted signing the papers.

Input

The first line contains two integers n and k (2 ≤ n ≤ 1001 ≤ k ≤ 1000). Each of the following n lines contains the coordinates of the polyline's endpoints. The i-th one contains coordinates of the point Ai — integers xi and yi, separated by a space.

All points Ai are different. The absolute value of all coordinates does not exceed 20. The coordinates are measured in millimeters.

Output

Print one real number — the total time Scrooges wastes on signing the papers in seconds. The absolute or relative error should not exceed 10 - 6.

Sample Input

Input
2 1 0 0 10 0
Output
0.200000000
Input
5 10 3 1 -5 6 -2 -1 3 2 10 0
Output
6.032163204
Input
6 10 5 0 4 0 6 0 3 0 7 0 2 0
Output
3.000000000

 

 
给出几个点速度是50求走过所有点的时间
1 #include
2 #include
3 int main() 4 { 5 int N,n,x,y,a = 0,b = 0; 6 double l = 0; 7 scanf("%d%d",&N,&n); 8 scanf("%d%d",&x,&y); 9 N--;10 while(N--)11 {12 a = x;13 b = y;14 scanf("%d%d",&x,&y);15 l += sqrt((x - a) * (x - a) *1.0 + 1.0*(y - b) * (y - b));16 17 }18 printf("%.6f",n*1.0*l/50.0);19 return 0;20 }
View Code
E - Canvas Frames
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.

Nicholas has n sticks whose lengths equal a1, a2, ... an. Nicholas does not want to break the sticks or glue them together. To make a h × w-sized frame, he needs two sticks whose lengths equal h and two sticks whose lengths equal w. Specifically, to make a square frame (when h = w), he needs four sticks of the same length.

Now Nicholas wants to make from the sticks that he has as many frames as possible; to be able to paint as many canvases as possible to fill the frames. Help him in this uneasy task. Note that it is not necessary to use all the sticks Nicholas has.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of sticks. The second line contains n space-separated integers. The i-th integer equals the length of the i-th stick ai (1 ≤ ai ≤ 100).

Output

Print the single number — the maximum number of frames Nicholas can make for his future canvases.

Sample Input

Input
5 2 4 3 2 3
Output
1
Input
13 2 2 4 4 4 4 6 6 6 7 7 9 9
Output
3
Input
4 3 3 3 5
Output
0

 

 
有n个棍 四个棍做一个矩形框,输出可以做几个框
1 #include
2 using namespace std; 3 #include
4 int a[220]; 5 int main() 6 { 7 int n; 8 int i; 9 int sum = 0,j = 0;10 cin>>n;11 for(i =0 ;i
>a[i];13 sort(a,a+n);14 15 for(i =0; i
View Code

C题虽然没有做出来 贴个大神代码瞻仰瞻仰

C - Message
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s.

String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba".

Dr. Moriarty plans to take string s and cut out some substring from it, let's call it t. Then he needs to change the substring t zero or more times. As a result, he should obtain a fixed string u (which is the string that should be sent to Sherlock Holmes). One change is defined as making one of the following actions:

  • Insert one letter to any end of the string.
  • Delete one letter from any end of the string.
  • Change one letter into any other one.

 

Moriarty is very smart and after he chooses some substring t, he always makes the minimal number of changes to obtain u.

Help Moriarty choose the best substring t from all substrings of the string s. The substring t should minimize the number of changes Moriarty should make to obtain the string u from it.

Input

The first line contains a non-empty string s, consisting of lowercase Latin letters. The second line contains a non-empty string u, consisting of lowercase Latin letters. The lengths of both strings are in the range from 1 to 2000, inclusive.

Output

Print the only integer — the minimum number of changes that Dr. Moriarty has to make with the string that you choose.

Sample Input

Input
aaaaa aaa
Output
0
Input
abcabc bcd
Output
1
Input
abcdef klmnopq
Output
7

Hint

In the first sample Moriarty can take any substring of length 3, and it will be equal to the required message u, so Moriarty won't have to make any changes.

In the second sample you should take a substring consisting of characters from second to fourth ("bca") or from fifth to sixth ("bc"). Then you will only have to make one change: to change or to add the last character.

In the third sample the initial string s doesn't contain any character that the message should contain, so, whatever string you choose, you will have to make at least 7 changes to obtain the required message.

 

 
给出两个字符串,对上一个字符串做改变,使其变成下一个字符串,可以从两端删除增加字符也可以改变任一个字符,输出最少需要改变的次数。
1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 16 #define CLR(arr,val) memset(arr,val,sizeof(arr))17 18 using namespace std;19 20 char s[2010], u[2010];21 22 int main()23 {24 std::ios::sync_with_stdio(false);25 #ifndef ONLINE_JUDGE26 freopen( "in.txt", "r", stdin );27 //freopen( "out.txt", "w", stdout );28 clock_t program_start, program_end;29 program_start = clock();30 #endif31 while ( cin >> s >> u )32 {33 int lens = strlen(s);34 int lenu = strlen(u);35 int min_res = lenu;36 //枚举起始位置37 //注意是允许从两边添加,因此要将目标串滑动到尾部与原始串开头对齐的程度。38 for ( int i = -lenu; i < lens; ++i )39 {40 int count = 0;41 for ( int j = i, k = 0; k < lenu; ++j, ++k )42 {43 if ( j < 0 || j >= lens || s[j] != u[k] )44 count++;45 }46 min_res = min( count, min_res );47 }48 cout << min_res << endl;49 }50 51 #ifndef ONLINE_JUDGE52 program_end = clock();53 cerr << "Time consumed: " << endl << ( program_end - program_start ) << " MS" << endl;54 #endif55 }
View Code
1 #include 
2 #include
3 4 using namespace std; 5 6 int array[2002][2002]; 7 8 int main() 9 {10 string str1, str2;11 12 while(cin >> str1 >> str2)13 {14 int len1 = str1.length();15 int len2 = str2.length();16 int minn = len2;17 18 for (int i = -len2; i < len1; i++)19 {20 int count = 0;21 for (int j = 0, t = i; j < len2; j++, t++)22 {23 if (str1[t] != str2[j] || t >= len1 || t < 0)24 {25 count++;26 }27 }28 minn = min(count, minn);29 }30 31 cout << minn << endl;32 }33 34 return 0;35 }
View Code
1 #include
2 #include
3 #include
4 #define N 2020 5 6 char a[N]; 7 char b[N]; 8 9 10 int main()11 {12 scanf("%s",a);13 scanf("%s",b);14 int n = strlen(a);15 int m = strlen(b);16 17 int ans = n+m;18 19 //左边加若干个20 for (int i=0;i<=m;i++)21 {22 int tmp = i;23 int k;24 for (k = 0;k
View Code

 

 

转载于:https://www.cnblogs.com/lwy-kitty/p/3203146.html

你可能感兴趣的文章
UITableViewCell contentView layoutSubviews 死循环
查看>>
安装 MYSQL exec: g++: not found 报错
查看>>
Springboot+redis 整合
查看>>
ZOJ Problem Set - 1002
查看>>
20181115 python-第一章学习小结part3
查看>>
uva 10034
查看>>
python 获取当前时间的用法
查看>>
谈谈Lucene和Solr索引存目录
查看>>
微信小程序 从本地相册选择图片或使用相机拍照chooseImage()和预览图片previewImage()...
查看>>
Vscode配置C++运行环境(2019/1//11更)并加入bits/stdc++.h头文件
查看>>
salesforce零基础学习(九十四)classic下pagelayout引入的vf page弹出内容更新此page layout...
查看>>
Web Server 启动工具
查看>>
eclipse oxygen离线安装activiti
查看>>
AngularJS学习
查看>>
单变量微积分笔记16——定积分的应用1(对数与面积)
查看>>
ACM模板——最短路
查看>>
实验3 分支语句和循环语句(1)
查看>>
Go语言实用技巧
查看>>
MySQL主从服务器的守护进程监视
查看>>
JSP页面上添加Fckeditor
查看>>