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. samba的使用

    第一步:了解它 为了实现Window主机与Linux服务器之间的资源共享,Linux操作系统提供了 Samba服务,Samba服务为两种不同的操作系统架起了一座桥梁,使 Linux 系统和Window ...

  2. CentOS7下Tomcat启动慢的原因及解决方案

    现象 在一次CentOS 7系统中安装Tomcat,启动过程很慢,需要几分钟,经过查看日志,发现耗时在这里:是session引起的随机数问题导致的.Tocmat的Session ID是通过SHA1算法 ...

  3. 原生js获取元素样式

    摘要: 我们在开发过程中经常会遇到通过js获取或者改变DOM元素的样式,方法有很多,比如:通过更改DOM元素的class.现在我们讨论原生js来获取DOM元素的CSS样式,注意是获取不是设置 在开始之 ...

  4. 怎样设置table中td的高度为1px

    在制作edm时会遇到须要设置td的高度为1px,假设td标签中有 时不管你怎么设置td的高度都没用,最小高度都是18px. 这时须要把表格中的 去掉.例: 原来是这种: <tr> < ...

  5. day26<网络编程>

    网络编程(网络编程概述) 网络编程(网络编程三要素之IP概述) 网络编程(网络编程三要素之端口号概述) 网络编程(网络编程三要素协议) 网络编程(Socket通信原理图解) 网络编程(UDP传输) 网 ...

  6. Hbase的基本认识

    1.使用场景:实时查询交互 说说概念性的东西,方便今后更加深入的理解. HBase是Apache Hadoop中的一个子项目,Hbase依托于Hadoop的HDFS作为最基本存储基础单元,通过使用ha ...

  7. oracle查锁表

    查锁表 select LOCK_INFO.OWNER || '.' || LOCK_INFO.OBJ_NAME as OBJ_NAME, -- 对象名称(已经被锁住) LOCK_INFO.SUBOBJ ...

  8. OAuth2认证有一定的了解

    转到分享界面后,进行OAuth2认证: 以新浪为例: 第一步.WebView加载界面,传递参数 使用WebView加载登陆网页,通过Get方法传递三个参数:应用的appkey.回调地址和展示方式dis ...

  9. 事件和winform的学习

             记得现在已经不在学习winform啦,可是我们为什么还是学习啦,我感觉就是帮助我们往下一个层次进发啦,因为从控制台直接开始进入webform的学习,我们很难接受啦,估计效率也不高啦, ...

  10. /usr/local/java/jdk1.8.0_11