B - B

内容:

    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.
Examples
Input 1
1 Output 3.1415926536 Input 3
1 4 2 Output 40.8407044967 Note 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π

水题,但是因为我把一个‘ * ’号写成了‘ - ’号没发现导致wa了好几次,还以为是超时了,气死。。。

代码:

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int n;
cin>>n;
int s[n+5];
for(int i=0;i<n;i++)
{
cin>>s[i];
}
sort(s,s+n,greater<int>());
double sum=0,p=3.141592653589;
if(n%2==0)
{
for(int i=0;i<n-1;i+=2)
{
sum+=p*(s[i]*s[i]-s[i+1]*s[i+1]);
}
printf("%.9lf\n",sum);
}
else{
for(int i=0;i<n-2;i+=2)
{
sum+=p*(s[i]*s[i]-s[i+1]*s[i+1]);//就是这里最后一个*号弄错了。。。
}
sum+=p*s[n-1]*s[n-1];
printf("%.9lf\n",sum);
}
}

C - C

内容:

    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.
Examples
Input aaaaa
aaa Output 0 Input abcabc
bcd Output 1 Input abcdef
klmnopq Output 7 Note 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.

题目大意:给出两个字符串s,u,通过将s中提取出的子字符串t 经过在任意一端删除字符,或在两端增加字符或者改变任意字符,使得t等于u;求最小操作数。

思路:顺序找到最长的匹配字符个数,再用len2减去,所得结果就是最少操作数。

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,t;
while(cin>>s>>t)
{
int len1=s.length(),len2=t.length();
int ans=1e9,i,j,len=len2;
for(i=0;i<len1;i++)
{
int k,ct=0;
for(k=0,j=i;k<len2&&j<len1;k++,j++)
{
if(t[k]==s[j])
ct++;
}
ans=min(ans,len-ct);
}
for(i=0;i<len2;i++)
{
int k,ct=0;
for(k=0,j=i;k<len1&&j<len2;k++,j++)
{
if(t[j]==s[k])
ct++;
}
ans=min(ans,len-ct);
}
cout<<ans<<endl;
}
}
题目内容:

    As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: "Which one committed the crime?". Suspect number i answered either "The crime was committed by suspect number ai", or "Suspect number ai didn't commit the crime". Also, the suspect could say so about himself (ai = i).

    Sherlock Holmes understood for sure that exactly m answers were the truth and all other answers were a lie. Now help him understand this: which suspect lied and which one told the truth?
Input The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ n) — the total number of suspects and the number of suspects who told the truth. Next n lines contain the suspects' answers. The i-th line contains either "+ai" (without the quotes), if the suspect number i says that the crime was committed by suspect number ai, or "-ai" (without the quotes), if the suspect number i says that the suspect number ai didn't commit the crime (ai is an integer, 1 ≤ ai ≤ n). It is guaranteed that at least one suspect exists, such that if he committed the crime, then exactly m people told the truth.
Output Print n lines. Line number i should contain "Truth" if suspect number i has told the truth for sure. Print "Lie" if the suspect number i lied for sure and print "Not defined" if he could lie and could tell the truth, too, depending on who committed the crime.
Examples
Input 1 1
+1 Output Truth Input 3 2
-1
-2
-3 Output Not defined
Not defined
Not defined Input 4 1
+2
-3
+4
-1 Output Lie
Not defined
Lie
Not defined Note The first sample has the single person and he confesses to the crime, and Sherlock Holmes knows that one person is telling the truth. That means that this person is telling the truth. In the second sample there are three suspects and each one denies his guilt. Sherlock Holmes knows that only two of them are telling the truth. Any one of them can be the criminal, so we don't know for any of them, whether this person is telling the truth or not. In the third sample the second and the fourth suspect defend the first and the third one. But only one is telling the truth, thus, the first or the third one is the criminal. Both of them can be criminals, so the second and the fourth one can either be lying or telling the truth. The first and the third one are lying for sure as they are blaming the second and the fourth one.

题意:

题意:福尔摩斯正在处理一件案子。此时已经抓捕了n个嫌疑人,里面只可能有一个是真正的犯人。福尔摩斯正在审问这些嫌疑人。
每个嫌疑人的回答只有两种,一种表明他说编号为i的嫌疑人不是犯人,用-i表示;另一种表明他说编号为i的嫌疑人是犯人,
用+i表示。聪明的福尔摩斯已经知道了其中有m个人说的是真话。要求那些人说的是真话,那些人说的是假话
思路:

首先判断每个人是逃犯的情况符不符合m个人说实话
然后判断合适的情况有多少
判断一个人是不是逃犯只要判断他被人说是逃犯和不说他是逃犯的人和等于m就可以了,因为如果他是逃犯那么这些人都没说谎。
然后通过可能发生的的事情的数量判断每个人说没说谎
如果一个人说另一个人是逃犯而这个人不可能是逃犯那么就是说谎
如果一个人说另一个人是逃犯而这个人确实可能是逃犯那么这个人说的话就不被确定
如果一个人说另一个人是逃犯而可能的事实只有一种那么他却说的就是实话而这个人是对的
如果一个人说其他人不是逃犯而这个人可能是逃犯那么他说的话就是不确定的
如果一个人说另一个人不是逃犯而这个人不可能是逃犯那么他说的就是对的
如果一个人说另一个人不是逃犯而这个人可能是逃犯并且事实唯一那么他就说了谎那么个人确实是逃犯

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int tu[100001], ky[100001], bky[100001], dui[100001],zgky=0,zgbky=0;
int main()
{
int n, m;
cin >> n >> m;
for (int a = 1; a <= n; a++)
{
scanf("%d", &tu[a]);
if (tu[a] < 0)bky[-tu[a]]++,zgbky++;
else ky[tu[a]]++, zgky++;
}
int kn = 0;
for (int a = 1; a <= n; a++)
{
if (ky[a] + zgbky - bky[a] == m)
{
kn++;
dui[a] = 1;
}
}
for (int a = 1; a <= n; a++)
{
if (tu[a] > 0)
{
if (!dui[tu[a]])printf("Lie\n");
else if (kn > 1)printf("Not defined\n");
else printf("Truth\n");
}
else
{
if(!dui[-tu[a]])printf("Truth\n");
else if (kn > 1)printf("Not defined\n");
else printf("Lie\n");
}
}
}

vj-2021.6.5-补题的更多相关文章

  1. 2021.1.28--vj补题

    B - B CodeForces - 994B 题内容: Unlike Knights of a Round Table, Knights of a Polygonal Table deprived ...

  2. 2021.02.21cf补题

    B. National Project 题意:总长度为n的公路进行维修,天气是有规律性的,连续g天的好天气,连续b天的坏天气,必须在好天气进行维护,问至少维护n的一半,那么至少需要多少天 思路:必须是 ...

  3. 2021.3.10--vj补题

    B - Saving the City cf--1443B Bertown is a city with nn buildings in a straight line. The city's sec ...

  4. 2021.3.3--vj补题

    题目 C - C CodeForces - 1166C The legend of the foundation of Vectorland talks of two integers xx and  ...

  5. 2021.2.23--vj补题

    B - B CodeForces - 699B 题目: You are given a description of a depot. It is a rectangular checkered fi ...

  6. 2021.1.23--vj补题

    B - B CodeForces - 879B n people are standing in a line to play table tennis. At first, the first tw ...

  7. hdu5017:补题系列之西安网络赛1011

    补题系列之西安网络赛1011 题目大意:给定一个椭球: 求它到原点的最短距离. 思路: 对于一个椭球的标准方程 x^2/a^2 + y^2/b^2 +z^2/c^2=1 来说,它到原点的最短距离即为m ...

  8. 2017河工大校赛补题CGH and 赛后小结

    网页设计课上实在无聊,便开始补题,发现比赛时候僵着的东西突然相通了不少 首先,"追妹"这题,两个队友讨论半天,分好多种情况最后放弃(可是我连题目都没看啊),今天看了之后试试是不是直 ...

  9. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  10. 2018 HDU多校第三场赛后补题

    2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...

随机推荐

  1. docker-compose权限不够

    root@kali:~# docker-compose version -bash: /usr/local/bin/docker-compose: 权限不够 chmod +x /usr/local/b ...

  2. 并发编程之:CountDownLatch

    大家好,我是小黑,一个在互联网苟且偷生的农民工. 先问大家一个问题,在主线程中创建多个线程,在这多个线程被启动之后,主线程需要等子线程执行完之后才能接着执行自己的代码,应该怎么实现呢? Thread. ...

  3. 痞子衡嵌入式:MCUXpresso IDE下将应用程序RW段分散链接的几种方法

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是MCUXpresso IDE下将应用程序RW段分散链接的几种方法. 早期的 MCU 芯片,一般都会嵌入内部 Flash 和 RAM,并且 ...

  4. 20210826 Lighthouse,Miner,Lyk Love painting,Revive

    考场 T1 这不裸的容斥 T2 这不裸的欧拉路,先从奇数度点开始走,走不了就传送 T3 什么玩意,暴力都不会 T4 点分树??? 仔细想了一波,发现 T1 T2 都好做,T3 二分答案后可以暴力贪心, ...

  5. QT程序打包成多平台可执行文件

    一.简述 QT项目开发完成后,需要打包发布程序,在实际生产中不可能把源码发给别人,所以需要将源码打包正可执行文件或者安装程序. 二.设置应用图标 把 ico 文件放到源代码目录下,在QT项目中的'.p ...

  6. container of()函数简介

    在linux 内核编程中,会经常见到一个宏函数container_of(ptr,type,member), 但是当你通过追踪源码时,像我们这样的一般人就会绝望了(这一堆都是什么呀? 函数还可以这样定义 ...

  7. Identity基于角色的访问授权

    详情访问官方文档 例如,以下代码将访问权限限制为属于角色成员的用户的任何操作 AdministrationController Administrator : [Authorize(Roles = & ...

  8. shell 脚本 根据PID过滤查看进程所有信息

    #!/bin/bash read -p "输入要查询的PID: " P #筛选第二列等于输入的PID号 n=`ps aux | awk '$2~/^'$P'$/ {print $1 ...

  9. oracle报错注入的一些函数

    oracle 报错注入 select dbms_xmltranslations.extractxliff((select banner from sys.v_$version where rownum ...

  10. Xilinx约束学习笔记(三)—— 时序概念

    3. 时序概念 发现对于时序基础的介绍这一块,Intel 的文档竟然要比 Xilinx 的详细,因此引用了很多 Intel 的文档内容. 3.1 术语 发送沿(launch edge),指用来发送数据 ...