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. zebra/quagga线程分析

    /* 线程按照不同的功能进行分类.有6条双链,分别表示不同类型的线程.将要运行的时候, * 就从不同的链表中取出,添加到ready链表中,运行完成之后,将线程结构体清空放到 * unuse链表中.一般 ...

  2. 第三百一十三节,Django框架,Session

    第三百一十三节,Django框架,Session Django中默认支持Session,其内部提供了5种类型的Session供开发者使用: 1.数据库(默认)2.缓存3.文件4.缓存+数据库5.加密c ...

  3. 有一个TIME的类要求输出分和秒的值

    #include <iostream> /* run this program using the console pauser or add your own getch, system ...

  4. 使用ffmpeg实现合并多个音频为一个音频的方法

    使用ffmpeg实现合并多个音频为一个音频的方法可以使用ffmpeg的filter功能来进行这个操作,而且效果很好amerge也可以实 使用ffmpeg实现合并多个音频为一个音频的方法 可以使用ffm ...

  5. vnc 多用户登录

    1, 创建新用户: $ useradd tom $ passwd tom 2,  登录到tom账户,创建vnc实例: $ su tom$ vncserver 这时可以看看~/.vnc/目录下,有一些如 ...

  6. 蔡勒(Zeller)公式

    来源好搜百科:http://baike.haosou.com/doc/1048888-1109421.html 蔡勒(Zeller)公式,是一个计算星期的公式,随便给一个日期,就能用这个公式推算出是星 ...

  7. MongoDB基础入门视频教程

    MongoDB基础入门视频教程http://www.icoolxue.com/album/show/98

  8. db2 over()

    说起 DB2 在线分析处理,可以用很好很强大来形容.这项功能特别适用于各种统计查询,这些查询用通常的SQL很难实现,或者根本就无发实现.首先,我们从一个简单的例子开始,来一步一步揭开它神秘的面纱,请看 ...

  9. NLP入门相关——学习笔记

    近义词.一词多义 GPT.ELMO.Bert

  10. plsql developer中,清除登录历史

    需求描述: 在使用plsql developer的时候,发现登录的时候,有太多的历史,想要把这些登录历史清除掉, 在此记录下. 操作过程: 1.登录plsql developer(或者在登录时取消也会 ...