pre过了三题 终测又挂了一题 又掉分了 真的是 太菜了

A-In Search of an Easy Problem

水题 有一个1就是hard

 #include <bits/stdc++.h>
using namespace std;
typedef long long int ll; int n; int main()
{
while(scanf("%d", &n) != EOF){
int easy;
bool flag = false;
for(int i = ; i < n; i++){
scanf("%d", &easy);
if(easy == ){
flag = true;
}
}
if(flag){
printf("HARD\n");
}
else{
printf("EASY\n");
}
}
return ;
}

B-Vasya and Cornfield

求一下四条边的直线方程 代入点判断即可

 #include <bits/stdc++.h>
using namespace std;
typedef long long int ll; int n, d, m;
struct node{
int x, y;
}; int main()
{
while(scanf("%d%d%d", &n, &d, &m) != EOF){
for(int i = ; i < m; i++){
int x, y;
scanf("%d%d", &x, &y);
if(y >= -x + d && y <= -x + * n - d && y >= x - d && y <= x + d){
printf("YES\n");
}
else{
printf("NO\n");
}
}
}
return ;
}

C-Vasya and Golden Ticket

终测挂了的题

求前缀和 对于每一个i看sum[n]是sum[i]的几倍 然后看i之后有没有1-k倍的sum[i]

挂了是因为没判断每个倍数都有 找到一个就输出了

 #include <bits/stdc++.h>
using namespace std;
typedef long long int ll; int n;
char s[];
int presum[]; int main()
{
while(scanf("%d", &n) != EOF){
memset(presum, , sizeof(presum));
scanf("%s", s + );
for(int i = ; i <= n; i++){
int t = s[i] - '';
presum[i] = presum[i - ] + t;
} bool flag = false;
if(presum[n] == ){
printf("YES\n");
continue;
}
//cout<<presum[n]<<endl;
for(int i = ; i <= n; i++){
if(presum[i] == ){
continue;
}
if(presum[n] % presum[i]){
continue;
}
else{
int k = presum[n] / presum[i];
if(k == ){
flag = true;
break;
}
int t = ;
for(int j = i + ; j <= n; j++){
if(presum[j] == (t) * presum[i]){
//cout<<k<<endl;
//cout<<i<<" "<<presum[i]<<endl;
//cout<<j<<" "<<presum[j]<<" "<<endl;
t++;
}
if(k == t){
flag = true;
break;
}
}
if(flag){
break;
}
}
} if(flag){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return ;
}

D-Vasya and Triangle

三角形公式S=(1/2)*(x1y2*1+x2y3*1+x3y1*1-x1y3*1-x2y1*1-x3y2*1) =1/2[x1(y2-y3)+x2(y3-y1)+x3(y1-y2)]

当2*n*m/k不是整数时一定没有解

有一个点一定是原点 否则一定可以将这个三角形平移到原点

剩下两个点一个点的横坐标和另一个点的纵坐标一定是0 因为这样就已经足够取尽n*m/2中的所有整数了

接下来就是如何凑出x2和y3了 使得x2 * y3 = 2 * n * m / k

应该想到的是gcd

假设a = gcd(2 * n, k) 那么S = (2 * n / a) * m / (k / a)

将他们分配一下 x2 = (2 * n / a), y3 = (m * a / k)

如果x2 或 y3超出范围限制了 就考虑把2这个系数挪一下就好了

 #include <bits/stdc++.h>
using namespace std;
typedef long long int LL; LL n, m, k; LL gcd(LL a, LL b)
{
if(b == )return a;
return gcd(b, a % b);
} int main()
{
while(scanf("%lld%lld%lld", &n, &m, &k) != EOF){
if(( * n * m) % k){
printf("NO\n");
}
else{
LL x1, x2, x3, y1, y2, y3;
x1 = 0ll; y1 = 0ll; x3 = 0ll; y2 = 0ll;
LL a = gcd( * n, k);
//cout<<a<<endl;
y3 = a * m / k;
x2 = * n / a;
//cout<<x2<<" "<<y3<<endl;
if(x2 > n || y3 > m){
y3 *= ;
x2 /= ;
}
/*if(n % k == 0){
y3 = m;
x2 = 2 * n / k;
}
else if(m % k == 0){
x2 = n;
y3 = 2 * m / k;
}
else{
/*int a = n / gcd(n, k);
int b = m / gcd(m, k);
if(a * 2 < n){
x2 = a * 2;
y3 = b;
}
else if(a * 2 < m){
y3 = a * 2;
x2 = b;
}
else if(b * 2 < n){
x2 = b * 2;
y3 = a;
}
else if(b * 2 < m){
y3 = b * 2;
x2 = a;
}
}*/
printf("YES\n");
printf("%lld %lld\n", x1, y1);
printf("%lld %lld\n", x2, y2);
printf("%lld %lld\n", x3, y3);
}
} return ;
}

codeforces#512 Div2的更多相关文章

  1. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  2. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  3. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  4. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  5. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  6. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  7. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  8. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  9. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. 第二百九十五节,python操作redis缓存-字符串类型

    python操作redis缓存-字符串类型 首先要安装redis-py模块 python连接redis方式,有两种连接方式,一种是直接连接,一张是通过连接池连接 注意:以后我们都用的连接池方式连接,直 ...

  2. jquery -- checkbox选中无选中状态

    最近在工作中使用jquery操作checkbox,使用下面方法进行全选.反选: var ischecked=allCheckObj.is(':checked'); ischecked?checksOb ...

  3. linux -- ubuntu14.10安装gnome桌面环境和dock工具

    ubuntu14.10系统自带Unity桌面环境,但是还是习惯于gnome桌面环境,再加上dock用着就很顺手了.   方法/步骤 首先,按Ctrl+Alt+T,调出终端.在其中输入:sudo apt ...

  4. Eclipse最经常使用快捷键总结

     1. ctrl+shift+r:打开资源 这可能是全部快捷键组合中最省时间的了. 这组快捷键能够让你打开你的工作区中不论什么一个文件,而你仅仅须要按下文件名称或mask名中的前几个字母,比方appl ...

  5. VNC轻松连接远程Linux桌面(1)

    Linux平台安装VNCServer Windows平台使用VNC-Viewer 方法/步骤     在Linux平台安装VNCServer服务端软件包. #yum -y install vnc *v ...

  6. oracle用sql 语句如何向表中插入时间?

    有关日期的操作中,更多的是涉及系统当前时间,用sysdate表示即可,如果是插入其他非系统时间的日期类型数据的话,用to_date转换再插入就可以了.例: insert into 表(c_date) ...

  7. 浅谈session测试

    Session 是用于保持状态的基于 Web 服务器的方法,在 Web 服务器上保持用户的状态信息供在任何时间从任何页访问.Session 允许通过将对象存储在 Web 服务器的内存中在整个用户会话过 ...

  8. git 分支的创建、合并、删除

          基本概念与命令 分支(branch):每次提交,Git都把提交的内容串成一条时间线,这条时间线就是一个分支 .   git 分支的创建 git branch branchName git ...

  9. SVN版控系统的安装和使用

    SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS.互联网上很多版本控制服务已从CVS迁移到Subversion ...

  10. JS怎样捕获浏览器关闭时间弹出自定义对话框

    <script type="text/javascript">window.onbeforeunload = function (e) { e = e || windo ...