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. Resource接口,及资源

    Resource介绍 编码的时候,除了代码本身,我们还需要对外部的资源进行处理.例如:URL资源.URI资源.File资源.ClassPath相关资源.服务器相关资源(VFS等)等等. 而这些资源的处 ...

  2. AMD和RequireJS初识----优化Web应用前端(按需动态加载JS)

    RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的RequireJS压缩后只有14K,堪称非常轻量.它还同时可以和其他的框架协同工作,使用Re ...

  3. iOS推送证书从申请到使用

    关于这个话题,已经有非常多写的非常好的文章了.可是,在自己做的过程中,即使别人写的已经非常好了,还是会遇到这样那样的问题. 自己还是再写一遍吧. 本文记录了从无到有申请证书,到最后可以发出通知.当然, ...

  4. haproxy+keepalived实现web集群高可用性[转]

    负载均衡集群的概念 负载均衡是设计分布式系统架构必须要考虑的因素之一,它指的是通过调度分发的方式尽可能将“请求”.“访问”的压力负载平均分摊到集群中的各个节点,避免有些节点负载太高导致访问延迟,而有些 ...

  5. php跨form提交方法

    1.php curl function curlPost($url,$params) { $postData = ''; foreach($params as $k => $v) { $post ...

  6. vc 获取 硬盘序列号 和 cpu

    vc 获取 硬盘序列号 和 cpu 唯一iD的方法?如题---------网上找来很多资料 也没找到, 要支持xp win7 32/64 系统下都能获取 硬盘序列号 和cpu ID 哪位朋友帮帮忙: ...

  7. POJ 3211 Washing Clothes 背包题解

    本题是背包问题,可是须要转化成背包的. 由于是两个人洗衣服,那么就是说一个人仅仅须要洗一半就能够了,由于不能两个人同一时候洗一件衣服,所以就成了01背包问题了. 思路: 1 计算洗完同一颜色的衣服须要 ...

  8. Android 下使用 JSON 实现 HTTP 请求

    不得不说,JSON 格式的确是非常美妙的,速度快而且简化了很多操作在 Android 下,Android SDK 已经为我们封装好了整个与 JSON 有关的操作,使用非常方便 以下就是一个标准的 JS ...

  9. 怎么让Word编辑公式又快又好

    现在很多办公学习都是在电脑中进行的.很多文件论文都是在Word中编写定稿以后再打印成册或者去投稿.毫无疑问,在Word中编辑各种各样的文字与符号是一项现在社会中非常必要的技能,而这其中一项就是对公式的 ...

  10. MFC中控件添加了变量后修改

    新增一个变量这个变量存在于两个位置,一个是头文件中项目名+Dlg.h文件,另一个是源文件中项目名+Dlg.cpp文件