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

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. DOM文档对象总结

    DOM总结: DOM:文档对象模型document object model DOM三层模型: DOM1:将HTML文档封装成对象 DOM2:将XML文档封装成对象 DOM3:将XML文档封装成对象 ...

  2. busying

    罪过 ,最近好忙  ,好久没有发表东西了, 连英语单词都写错了

  3. (转)使用 /proc 文件系统来访问 Linux 内核的内容

    转载网址:http://www.ibm.com/developerworks/cn/linux/l-proc.html 这个虚拟文件系统在内核空间和用户空间之间打开了一个通信窗口/proc 文件系统是 ...

  4. 机器学习中的数学-线性判别分析(LDA), 主成分分析(PCA)

    转:http://www.cnblogs.com/LeftNotEasy/archive/2011/01/08/lda-and-pca-machine-learning.html 版权声明: 本文由L ...

  5. EBP的妙用[无法使用ESP定律时]

    1.了解EBP寄存器 在寄存器里面有很多寄存器虽然他们的功能和使用没有任何的区别,但是在长期的编程和使用 中,在程序员习惯中已经默认的给每个寄存器赋上了特殊的含义,比如:EAX一般用来做返回值,ECX ...

  6. NOI 国家集训队论文集

    鉴于大家都在找这些神牛的论文.我就转载了这篇论文合集 国家集训队论文分类 组合数学 计数与统计 2001 - 符文杰:<Pólya原理及其应用> 2003 - 许智磊:<浅谈补集转化 ...

  7. HTTP 408请求超时错误解决办法

    错误描述 对于大多数网站而言,我们所看到的错误消息已经是开发者定制过的页面,比如我们最常见的自定义404错误页面,一般而言,我们看到的408错误应该是类似这样的提示:“408:Request Time ...

  8. PowerDesigner修改设计图中文字的字体大小等样式

    设计图中默认的字体是对英文比较合适的,中文就看不清楚了,特别不美观.但是可以通过修改“Display Preferences”适应我们的汉字. 我使用的PowerDesigner版本是15.1(测试版 ...

  9. Mac 如果一定要写个锁屏程序的话就这样

    package test; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import ...

  10. Tomcat7.0 start Could not find the main class: org.apache.catalina.startup.Bootstrap.

    java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory at org.apache.catalina.startup.Bo ...