这是做的最好的一次了一共做了4道题  嘻嘻~
A - Game Outcome

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

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

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

 #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 ;
}
B - Trace

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

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 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 ;
}
D - Wasted Time

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

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求走过所有点的时间
 #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 ;
}
E - Canvas Frames

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

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个棍 四个棍做一个矩形框,输出可以做几个框
 #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题虽然没有做出来 贴个大神代码瞻仰瞻仰

C - Message

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

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.

 给出两个字符串,对上一个字符串做改变,使其变成下一个字符串,可以从两端删除增加字符也可以改变任一个字符,输出最少需要改变的次数。
 #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的更多相关文章

  1. OUC_Summer Training_ DIV2_#16 725

    今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...

  2. OUC_Summer Training_ DIV2_#13 723afternoon

    A - Shaass and Oskols Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  3. OUC_Summer Training_ DIV2_#12(DP1) 723

    这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS     Memory Limit:32768KB   ...

  4. OUC_Summer Training_ DIV2_#14 724

    又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS     Memory Limit:262144KB     64bit IO F ...

  5. OUC_Summer Training_ DIV2_#2之解题策略 715

    这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...

  6. OUC_Summer Training_ DIV2_#7 718

    是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS     Memory ...

  7. OUC_Summer Training_ DIV2_#11 722

    企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  8. OUC_Summer Training_ DIV2_#9 719

    其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...

  9. OUC_Summer Training_ DIV2_#4之数据结构

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS     Me ...

随机推荐

  1. nfs服务器的搭建和使用

    目录 更新记录 1.nfs介绍 1.1 nfs概念 1.2 nfs工作原理 1.3 nfs通讯过程 2.搭建和测试 NFS 服务器 2.1 搭建NFS服务器 2.2 测试NFS服务器 3.在线调试:N ...

  2. 帝国cms列表内容模板加上数字编号

    /*这个[!--no.num--]指的是信息编号.每次增加1*/ <li data-eq="[!--no.num--]"> <div class="ti ...

  3. Winfrom 极简版贪吃蛇源码

    该源码是我在百度知识库借助前辈的的经验,加上自己的一点小改动写的一个非常简陋的贪吃蛇小程序.如果你们有更好的改动方案,欢迎评论. 进入主题吧! 1.创建一个桌面应运程序,拖一个定时器控件.这样,程序界 ...

  4. JSP中的普通路径写法

    <% String path = request.getContextPath();     String basePath = request.getScheme()+"://&qu ...

  5. mysql中取出的时间日期多个.0

    字段名称为 create_time 字段类型为 datetime 存储的内容为 2019-03-26 09:42:05 但是 通过mybatis取出来放到实体类里,数值就变成了 2019-03-26 ...

  6. Linux中 tr 命令详解

    tr - translate or delete characters 主要用于转换和删除字符 带有最常用选项的t r命令格式为:tr -c -d -s [ "string1_to_tran ...

  7. Java学习笔记【四、类、对象、接口】

    编程语言的发展 机器语言 过程语言 面向对象编程--封装.继承.多态 关键字 extends implements override overload super this static abstra ...

  8. (七)make menuconfig

    1.make menuconfig进入图形界面后,输入 / 进行查找页面,如果输入有错,要删除前面输入的可以输入 ctrl加<--键(ctrl加回退按键)

  9. 三、Nginx支持php

    一.php fastcgi配置(分析宝塔的) 因为只是配置PHP,所以只需要改动server部分 关于phpmyadmin这个站点的信息: 查找该文件:

  10. mysql数据库:数据类型、存储引擎、约束、

      1.详细的建表语句 *****    create table 表名( 字段名 数据类型[(长度) 约束条件] );    []代表可选的    为什么需要给数据分类?        189  一 ...