OUC_Summer Training_ DIV2_#5
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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
1
1
0
2
1 2
3 4
2
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
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
题目的意思大概是以一个格子为准列和大于行和的总数 暴力写的
#include<stdio.h>
int a[][];
int main()
{
int n,i,j,k,sum1 = ,sum2 = ,m = ;
scanf("%d",&n);
for(i = ;i < n;i++)
{
for(j = ;j < n;j++)
scanf("%d",&a[i][j]);
}
for(i = ;i < n;i++)
{
for(j = ;j < n;j++)
{
for(k = ;k < n;k++)
{
sum1 += a[i][k];
sum2 += a[k][j];
}
if(sum1 < sum2)m++;
sum1 = ;
sum2 = ;
} }
printf("%d",m);
return ;
}
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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
1
1
3.141592653589793
3
1 4 2
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 1, 4 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π
题目的意思大概是 有好几个同心圆 分别给出半径 给同心圆涂颜色 最外面的区域是蓝色的 整个平面的颜色是蓝红相间的求红色区域的面积
没什么好说的,直接做就好了。
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#define PI acos(-1.0)
int a[];
int main()
{
int n,i,j = ,sum = ;
double s;
cin >> n;
for(i = ;i < n;i++)
cin >> a[i];
sort(a,a+n);
for(i = n-;i >= ;i-- )
{
if(j == )
{
sum += a[i] * a[i];
j = ;
}
else if(j == )
{
sum -= a[i] * a[i];
j = ;
}
}
s = sum * PI;
cout << s;
return ;
}
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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 ≤ 100, 1 ≤ 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
2 1
0 0
10 0
0.200000000
5 10
3 1
-5 6
-2 -1
3 2
10 0
6.032163204
6 10
5 0
4 0
6 0
3 0
7 0
2 0
3.000000000
#include<stdio.h>
#include<math.h>
int main()
{
int N,n,x,y,a = ,b = ;
double l = ;
scanf("%d%d",&N,&n);
scanf("%d%d",&x,&y);
N--;
while(N--)
{
a = x;
b = y;
scanf("%d%d",&x,&y);
l += sqrt((x - a) * (x - a) *1.0 + 1.0*(y - b) * (y - b)); }
printf("%.6f",n*1.0*l/50.0);
return ;
}
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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
5
2 4 3 2 3
1
13
2 2 4 4 4 4 6 6 6 7 7 9 9
3
4
3 3 3 5
0
#include<iostream>
using namespace std;
#include<algorithm>
int a[];
int main()
{
int n;
int i;
int sum = ,j = ;
cin>>n;
for(i = ;i <n ;i++)
cin>>a[i];
sort(a,a+n); for(i =; i<n;i++)
{
if(a[i] == a[i+])
{
if(j == )
j = ;
else j =;
if(j == )sum ++;
}
else
if(j !=)j =;
}
cout<<(sum/)<<endl;
return ;
}
C题虽然没有做出来 贴个大神代码瞻仰瞻仰
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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
aaaaa
aaa
0
abcabc
bcd
1
abcdef
klmnopq
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.
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <climits>
#include <ctime>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <iomanip> #define CLR(arr,val) memset(arr,val,sizeof(arr)) using namespace std; char s[], u[]; int main()
{
std::ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen( "in.txt", "r", stdin );
//freopen( "out.txt", "w", stdout );
clock_t program_start, program_end;
program_start = clock();
#endif
while ( cin >> s >> u )
{
int lens = strlen(s);
int lenu = strlen(u);
int min_res = lenu;
//枚举起始位置
//注意是允许从两边添加,因此要将目标串滑动到尾部与原始串开头对齐的程度。
for ( int i = -lenu; i < lens; ++i )
{
int count = ;
for ( int j = i, k = ; k < lenu; ++j, ++k )
{
if ( j < || j >= lens || s[j] != u[k] )
count++;
}
min_res = min( count, min_res );
}
cout << min_res << endl;
} #ifndef ONLINE_JUDGE
program_end = clock();
cerr << "Time consumed: " << endl << ( program_end - program_start ) << " MS" << endl;
#endif
}
#include <iostream>
#include <string> using namespace std; int array[][]; int main()
{
string str1, str2; while(cin >> str1 >> str2)
{
int len1 = str1.length();
int len2 = str2.length();
int minn = len2; for (int i = -len2; i < len1; i++)
{
int count = ;
for (int j = , t = i; j < len2; j++, t++)
{
if (str1[t] != str2[j] || t >= len1 || t < )
{
count++;
}
}
minn = min(count, minn);
} cout << minn << endl;
} return ;
}
#include<stdio.h>
#include<math.h>
#include<string.h>
#define N 2020 char a[N];
char b[N]; int main()
{
scanf("%s",a);
scanf("%s",b);
int n = strlen(a);
int m = strlen(b); int ans = n+m; //左边加若干个
for (int i=;i<=m;i++)
{
int tmp = i;
int k;
for (k = ;k<n && i+k<m;k++)
{
if (a[k] == b[i+k])
continue;
else
tmp++;
}
if (k<n)
{
// tmp += (n-k);
}else if (k+i<m){
tmp += (m-k-i);
}
if (tmp < ans)
ans = tmp;
}
//左边切去若干个
for (int i=;i<=n;i++)
{
int tmp = ;
int k;
for (k=;k<m && k+i<n;k++)
{
if (b[k] == a[i + k])
continue;
else
tmp++;
}
if (k < m)
{
tmp += (m - k);
}else if (k < n)
{
// tmp += (n - k);
}
if (tmp < ans)
ans = tmp;
}
printf("%d\n",ans);
return ;
}
OUC_Summer Training_ DIV2_#5的更多相关文章
- OUC_Summer Training_ DIV2_#16 725
今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...
- OUC_Summer Training_ DIV2_#13 723afternoon
A - Shaass and Oskols Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- OUC_Summer Training_ DIV2_#12(DP1) 723
这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS Memory Limit:32768KB ...
- OUC_Summer Training_ DIV2_#14 724
又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS Memory Limit:262144KB 64bit IO F ...
- OUC_Summer Training_ DIV2_#2之解题策略 715
这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...
- OUC_Summer Training_ DIV2_#7 718
是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS Memory ...
- OUC_Summer Training_ DIV2_#11 722
企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- OUC_Summer Training_ DIV2_#9 719
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...
- OUC_Summer Training_ DIV2_#4之数据结构
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS Me ...
随机推荐
- std::list保存大量数据时,类型即是无析构函数,该list析构时会占用大量CPU
std::list保存大量数据时,类型即是无析构函数,该list析构时会占用大量CPU
- js之数据类型(对象类型——构造器对象——对象)
JavaScript中除了原始类型,null,undefined之外就是对象了,对象是属性的集合,每个属性都是由键值对(值可以是原始值,比如说是数字,字符串,也可以是对象)构成的.对象又可分为构造器对 ...
- 前后端分离-模拟数据之RAP2快速入门
是啥? RAP是一个可视化接口管理工具 通过分析接口结构,动态生成模拟数据,校验真实接口正确性, 围绕接口定义,通过一系列自动化工具提升我们的协作效率.我们的口号:提高效率,回家吃晚饭! 可视化编辑, ...
- 简单聊聊服务发现(redis, zk,etcd, consul)(转载)
服务发现并没有怎样的高深莫测,它的原理再简单不过.只是市面上太多文章将服务发现的难度妖魔化,读者被绕的云里雾里,顿觉自己智商低下不敢高攀. 服务提供者是什么,简单点说就是一个HTTP服务器,提供了AP ...
- mybatis批量更新表setting parameters 错误
mybatis中想用 foreach标签 批量update set表 下面是mapper.xml <update id="updateMonitorById" paramet ...
- linux 删除文件空间未释放问题
现象:我们测试环境上,导出数据文件时,由于作业报错,重复导出,空间使用到达100%,按理说,导出的文件时在相同的路径下,文件名也是一致的,会自动替换. 那么之前导出的文件会被删除,问题就出现在删除这一 ...
- Redis03——Redis架构
Redis架构 1.1.问题 redis是单线程,单实例,为什么并发那么多,依旧很快呢? 回答:因为调用了系统内核的epoll 1.2.Linux的早期版本 Linux有Linux kernal,我们 ...
- IntelliJ IDEA导包快捷键
IntelliJ IDEA导包快捷键 Alt+Enter
- servlet 如何处理多请求访问以及线程讲解
servlet 如何处理多请求访问以及线程讲解 场景:js循环500次请求同一个后台接口,接口内部逻辑:1.查询商品数量,2.扣减商品数量 ,那么该接口是否需要考虑多线程并发安全问题? 分析: 1.先 ...
- web 9个令人震惊的WebGL示例
20个使用WebGL和Three.js实现的网页场景 https://www.open-open.com/news/view/9d8136 20个使用WebGL和Three.js实现的网页场景 htt ...