做了三个题,先贴一下代码。。。终于涨分了

A. Line to Cashier

水题

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

B. Garland

两个字符串 代表两串颜色。

下面的要构造的颜色 上面的必须有,求上面的能构造的最大的值。

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

C. Triangle

题意:一个直角三角形,任何边都不和坐标轴平行,给定两个腰长,顶点的坐标为整数。求这个三角形的三个顶点坐标。

可能有很多符合条件的。。

思路:以给定的两个腰长,分别做圆,从左到右枚举每个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 ;
}

D. Long Path

题意:有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)的更多相关文章

  1. Codeforces Round #239 (Div. 1)C, 407C

    题目链接:http://codeforces.com/contest/407/problem/C 题目大意:给一个长度为n的数列,m次操作,每次操作由(li, ri, ki)描述,表示在数列li到ri ...

  2. Codeforces Round #239 (Div. 2) C. Triangle

    time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard o ...

  3. Codeforces Round #239 (Div. 1) 二项式差分

    C - Curious Array 思路:对于区间[l, r]每个数加上C(i - l + k, k), 可以在l处+1, 在r+1处-1, 然后做k+1次求前缀和操作,然后就可以写啦. 然后逐层求前 ...

  4. Codeforces Round #239(Div. 2) 做后扯淡玩

    今天补了下 cf 239div2 顿时信心再度受挫 老子几乎已经木有时间了啊 坐着等死的命.哎!!! 到现在还只能做大众题,打铁都不行. 每次D题都是有思路敲错,尼玛不带这么坑爹的. 哎!不写了,写这 ...

  5. Codeforces Round #239 (Div. 1)

    B. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  6. 【Codeforces Round #239 (Div. 1) B】 Long Path

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] DP,设f[i]表示第一次到i这个房间的时候传送的次数. f[1] = 0,f[2] = 2 考虑第i个位置的情况. 它肯定是从i- ...

  7. 【Codeforces Round #239 (Div. 1) A】Triangle

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后的直角三角形可以通过平移,将直角顶点移动到坐标原点. 然后我们只要枚举另外两个点其中一个点的坐标就好了. x坐标的范围是[1.. ...

  8. 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 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. JDBC 学习笔记(四)—— 自定义JDBC框架+Apache—DBUtils框架+事务管理+操作多表

    本文目录:       1.自定义JDBC框架 ——数据库元数据:DataBaseMetaData        2.自定义JDBC框架 ——数据库元数据:DataBaseMetaData       ...

  2. [搜片神器]winform程序自己如何更新自己的方法代码

    DHT抓取程序开源地址:https://github.com/h31h31/H31DHTDEMO 数据处理程序开源地址:https://github.com/h31h31/H31DHTMgr 国外测试 ...

  3. c# XAML

    http://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/hh465340.aspx 如果你选择在 Microsoft Visual Basi ...

  4. 【转载】Spring中DispatcherServlet与ContextLoaderListener的区别

    昨天在写springmvc的时候,在web.xml中配置了DispatcherServlet,如下: <servlet> <servlet-name>DispatcherSer ...

  5. linux cmake 安装mysql5.5.11,以及更高版本

    1.下载mysql5.5.12和cmake wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.12-linux2.6-i686.tar.gz ...

  6. uLua 学习笔记 之一 lua脚本 打包与读取

    最近要学习热更新,搜了下,选择了ulua这个插件,本人也是新人.对这个插件也是一知半解,不过幸好加了专门讨论这一块的群,这个群的技术氛围还是很浓重的,特别是已经形成了一套自己的lua学习框架.最近周末 ...

  7. Unity3D研究院之IOS全自动打包生成ipa

    接着上一篇文章, 自动生成framework,这篇文章我把shell自动化打包ipa整理了一下,希望大家喜欢,嘿嘿.. 建议大家先看一下上一篇文章.http://www.xuanyusong.com/ ...

  8. Properties --- C++读配置信息的类(一)

    http://blog.csdn.net/billow_zhang/article/details/4304980 在开发实践中,积累了一些通用的C++ 类库,在此写出来给大家分享.也希望能给出更好的 ...

  9. javascript分享到的源码

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  10. POJ 3440 Coin Toss(求概率)

    题目链接 题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率. 思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次..... #include ...