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

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. Ext学习-HelloWorld以及基础环境搭建

    1.目的    在eclipse中搭建EXTJS的基础环境,学习如何按照从官方下载的代码中搭建新的Extjs工程 2.主要包含内容:   1.ExtJS文件下载以及目录说明   2.ExtJS开发环境 ...

  2. 【BZOJ】【2844】albus就是要第一个出场

    高斯消元解XOR方程组 srO  ZYF  Orz 膜拜ZYF…… http://www.cnblogs.com/zyfzyf/p/4232100.html /******************** ...

  3. 剑指offer--面试题10

    题目:求整数二进制表示中1的个数. 分析:此题直接考查二进制表示与位运算!!! 正数和负数的二进制表示不同!在计算机中,正数的二进制表示即为通常所写的二进制:而负数的二进制表示则用补码表示,即原码的反 ...

  4. SQL Server 之 事务隔离级别

    SET TRANSACTION ISOLATION LEVEL xxx  -- 每次设置只针对当前事务块 xxx 取值: READ UNCOMMITTED READ COMMITTED REPEATA ...

  5. MATLAB——PLOT绘图

    MATLAB——PLOT绘图 格式化绘图: 1.color: b g  r c m y k w blue green red  cyan magenta yellow black white 2.ty ...

  6. linux系统进程的内存布局

    内存管理模块是操作系统的心脏:它对应用程序和系统管理非常重要.今后的几篇文章中,我将着眼于实际的内存问题,但也不避讳其中的技术内幕.由于不少概念是通用的,所以文中大部分例子取自32位x86平台的Lin ...

  7. 基于EBP的栈帧

    程序的OEP,一开始以 push ebp 和mov ebp esp这两句开始.   原因:c程序的开始是以一个主函数main()为开始的,而函数在访问的过程中最重要的事情就是要确保堆栈的平衡,而在wi ...

  8. java核心技术记录之集合

    java库中的具体集合: 集合类型 描述 ArrayList 一种可以动态增长和缩减的索引序列 LinkedList 一种可以在任何位置进行高效地插入和删除操作的有序序列 ArrarDeque 一种用 ...

  9. Git fetch和git pull的区别(转)

    原文: http://www.tech126.com/git-fetch-pull/ Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地 ...

  10. 关于Python的super用法

    Python中对象方法的定义很怪异,第一个参数一般都命名为self(相当于其它语言的this),用于传递对象本身,而在调用的时候则不必显式传递,系统会自动传递. 举一个很常见的例子: >> ...