Codeforces Round #239 (Div. 2)
做了三个题,先贴一下代码。。。终于涨分了
水题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF = (<<); int main()
{
int Min, n, a[], ans;
int i, j;
while(cin>>n)
{
Min = INF;
for(i = ; i < n; i++)
cin>>a[i];
for(i = ; i < n; i++)
{
ans = a[i]*;
for(j = ; j < a[i]; j++)
{
int b;
cin>>b;
ans += b*;
}
if(ans<Min)
Min = ans;
}
cout<<Min<<endl;
}
return ;
}
两个字符串 代表两串颜色。
下面的要构造的颜色 上面的必须有,求上面的能构造的最大的值。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = +; char a[maxn], b[maxn];
int f_a[], f_b[];
int main()
{
int i, j;
int len_a, len_b, f, ans;
while(cin>>a>>b)
{
f = ; ans = ;
memset(f_a, , sizeof(f_a));
memset(f_b, , sizeof(f_b));
len_a = strlen(a);
len_b = strlen(b);
for(i = ; i < len_a; i++)
f_a[a[i]-'a']++;
for(j = ; j < len_b; j++)
f_b[b[j]-'a']++;
for(i = ; i < ; i++)
{
if(f_b[i]>&&f_a[i]==)
f = ;
}
if(f)
cout<<ans-<<endl;
else
{
for(i = ; i < ; i++)
{
if(f_a[i]>f_b[i])
ans += f_b[i];
else
ans += f_a[i];
}
cout<<ans<<endl;
}
}
return ;
}
题意:一个直角三角形,任何边都不和坐标轴平行,给定两个腰长,顶点的坐标为整数。求这个三角形的三个顶点坐标。
可能有很多符合条件的。。
思路:以给定的两个腰长,分别做圆,从左到右枚举每个x整数点, 若y点也为整数,就保存。
最后, 让两个保存的数组,任意组合。找互相垂直,而且不与坐标轴平行的输出。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = +;
const double eps = 1e-;
struct node
{
int x, y;
} a[maxn], b[maxn]; int main()
{
int a1, b1, i, j;
int aa, bb, cnt_a, cnt_b;
double m;
int n, f;
while(cin>>a1>>b1)
{
f = ;
aa = a1*a1;
bb = b1*b1;
cnt_a = ;
cnt_b = ;
for(i = -a1+; i < a1; i++)
{
if(i==)
continue;
n = sqrt(aa-i*i);
m = (double)(sqrt(aa-i*i));
if(fabs(n-m)<eps)
{
a[cnt_a].x = i;
a[cnt_a++].y = n;
}
}
for(i = -b1+; i < b1; i++)
{
if(i==)
continue;
n = sqrt(bb-i*i);
m = (double)(sqrt(bb-i*i));
if(fabs(n-m)<eps)
{
b[cnt_b].x = i;
b[cnt_b++].y = n;
}
}
//for(i = 0; i < cnt_b; i++)
//printf("%d %d\n", b[i].x, b[i].y);
for(i = ; i < cnt_a; i++)
{
for(j = ; j < cnt_b; j++)
{
if(a[i].x*b[j].x+a[i].y*b[j].y==&&a[i].x!=b[j].x&&a[i].y!=b[j].y)
{
cout<<"YES"<<endl;
printf("%d %d\n", a[i].x, a[i].y);
printf("%d %d\n", b[j].x, b[j].y); a1 = ;
b1 = ;
printf("%d %d\n", a1, b1);
f = ;
break;
}
}
if(f)
break;
}
if(f==)
cout<<"NO"<<endl;
}
return ;
}
题意:有n+1个房间,现在人在1号房间,问到 n+1个房间,需要多少步。
每个房间都有两个门,当你进入这个房间的次数是 奇数次的时候走第1个门 进入房间p[i].
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int mo = +;
const int maxn = +;
int p[maxn], d[maxn]; int main()
{
int n, i, j;
int ans;
while(cin>>n)
{
memset(d, , sizeof(d));
for(i = ; i <= n; i++)
cin>>p[i];
d[] = ;
for(i = ; i <= n; i++)
{
for(j = p[i]; j < i; j++)
{
d[i] += d[j];
d[i] %= mo;
}
d[i] += ;
d[i] %= mo;
}
ans = ;
for(i = ; i <= n; i++)
ans = (ans + d[i])%mo;
cout<<ans<<endl;
}
return ;
}
Codeforces Round #239 (Div. 2)的更多相关文章
- Codeforces Round #239 (Div. 1)C, 407C
题目链接:http://codeforces.com/contest/407/problem/C 题目大意:给一个长度为n的数列,m次操作,每次操作由(li, ri, ki)描述,表示在数列li到ri ...
- Codeforces Round #239 (Div. 2) C. Triangle
time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard o ...
- Codeforces Round #239 (Div. 1) 二项式差分
C - Curious Array 思路:对于区间[l, r]每个数加上C(i - l + k, k), 可以在l处+1, 在r+1处-1, 然后做k+1次求前缀和操作,然后就可以写啦. 然后逐层求前 ...
- Codeforces Round #239(Div. 2) 做后扯淡玩
今天补了下 cf 239div2 顿时信心再度受挫 老子几乎已经木有时间了啊 坐着等死的命.哎!!! 到现在还只能做大众题,打铁都不行. 每次D题都是有思路敲错,尼玛不带这么坑爹的. 哎!不写了,写这 ...
- Codeforces Round #239 (Div. 1)
B. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- 【Codeforces Round #239 (Div. 1) B】 Long Path
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] DP,设f[i]表示第一次到i这个房间的时候传送的次数. f[1] = 0,f[2] = 2 考虑第i个位置的情况. 它肯定是从i- ...
- 【Codeforces Round #239 (Div. 1) A】Triangle
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后的直角三角形可以通过平移,将直角顶点移动到坐标原点. 然后我们只要枚举另外两个点其中一个点的坐标就好了. x坐标的范围是[1.. ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 微软职位内部推荐-Senior Software Development En
微软近期Open的职位: Job Title: Senior Development Engineer Division: Visual Studio China - Developer Divisi ...
- SharePoint 101 Code Samples are now available
The Microsoft Office Developer Center has created 101 code samples for SharePoint 2010. These sample ...
- LoadRunner 学习笔记(1)性能测试常见术语
并发用户数据:与服务器进行交互的在线用户数量 请求响应时间:从Client端发出请求到得到响应的整个时间 一般包括网络响应时间 + server的响应时间 事务请求响应时间:完成这个事务所用的时间 这 ...
- 利用QObject反射实现jsonrpc
1.jsonrpc请求中的params数组生成签名 static QString signatureFromJsonArray(const QJsonArray &array) { QStri ...
- JS实现Web网页打印功能(IE)
问题描述: JS实现Web网页打印功能 问题解决: 这里主要使用WebBrowser控件的ExeWB在IE中打印功能的实现 WebBrowser介绍: WebBrows ...
- 20160728noip模拟赛zld
前言:单独对题面描述的评分-> [题解]把相邻长度为2的子串两两连边,跑欧拉路 /*明天再写,先贴一份方老师代码压压惊*/ #include<map> #include<sta ...
- unity3d结合轮廓显示,实现完整的框选目标(附Demo代码)
原地址:http://dong2008hong.blog.163.com/blog/static/469688272013111554511948/ 在unity里实现,其实很简单,因为有两个前提:1 ...
- hdu 2717 Catch That Cow(BFS,剪枝)
题目 #include<stdio.h> #include<string.h> #include<queue> #include<algorithm> ...
- 【转】Android 实现“再按一次退出程序”
From:http://blog.csdn.net/ldj299/article/details/7574365 个人觉得当用户按下后退键时,出现"再按一次退出"的提示防止误操作比 ...
- MAC OS JAVA环境变量配置
在 /etc/profile 中 加上这些 #临时提权 sudo su #输入密码 vi /etc/profile #配置JAVA_HOME,此处路径根据自己的版本填写 JAVA_HOME=&quo ...