DEF 题对于 wyh 来说过于毒瘤,十分不可做。

A. Heating

Description:

给定\(a,b\),将\(b\)分成至少\(a\)个正整数,使这些正整数的平方和最小。

Solution:

sb题,3minA掉,但是提交代码花了我近20min

Code:


#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; typedef long long ll;
int T;
int a,b; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&a,&b);
if(a>b){printf("%d\n",b);continue;}
int ans=(b%a)*(b/a+1)*(b/a+1)+(a-b%a)*(b/a)*(b/a);
printf("%d\n",ans);
}
return 0;
}

B. Obtain Two Zeroes

Description:

给定\(a,b\)和两种变化规则:

\[a=a−x , b=b−2x
\]

\[a=a−2x , b=b−x
\]

问能不能将\(a,b\)都变成0

Solution:

对 mod 3 余数讨论即可。

Code:


#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; typedef long long ll;
ll T;
ll a,b; int main()
{
cin>>T;
while(T--)
{
cin>>a>>b;
if(a>b) swap(a,b);
if((a*2-b)%3||a*2<b) printf("NO\n");
else printf("YES\n"); }
return 0;
}

C. Infinite Fence

Description:

给定\(a,b,k\),将a的倍数涂成红色,b的倍数涂成蓝色,a和b的公倍数随便涂,问是否存在一种方案,使得将涂色的数字从小到大排序后,不存在连续k个数是同一种颜色。

Solution:

结论:将\(a\)与\(b\)同除以\(gcd(a,b)\),结果不变。

这样我们就可以使\(a,b\)互质。假设\(a<=b\),然后判断啊\(a*(k-1)+1\)与\(b\)的关系就行了。具体见代码。

Code:


#include<iostream>
#include<cstdio> using namespace std; typedef long long ll;
ll T,r,b,k; ll gcd(ll a,ll b)
{
if(!b) return a;
return gcd(b,a%b);
} int main()
{
scanf("%lld",&T);
while(T--)
{
scanf("%lld%lld%lld",&r,&b,&k);
ll g=gcd(r,b);r/=g;b/=g;if(r>b) swap(r,b);
if(r*(k-1)+1>=b) printf("OBEY\n");
else printf("REBEL\n");
}
return 0;
}

Codeforces 1260 ABC的更多相关文章

  1. codeforces CF475 ABC 题解

    Bayan 2015 Contest Warm Up http://codeforces.com/contest/475 A - Bayan Bus B - Strongly Connected Ci ...

  2. Codeforces 802 ABC. Heidi and Library

    题目大意 你需要保证第\(i\)天时有第\(a_i\)种书.你可以在任何一天买书,买第\(i\)种书的代价为\(c_i\). 你最多同时拥有\(k\)本书,如果此时再买书,则必须先扔掉已拥有的一本书. ...

  3. [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)

    Problem 遗产 题目大意 给出一个带权有向图,有三种操作: 1.u->v添加一条权值为w的边 2.区间[l,r]->v添加权值为w的边 3.v->区间[l,r]添加权值为w的边 ...

  4. 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 ...

  5. Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 【ABC】

    老年人题解,语言python3 A - Bank Robbery 题意:给你ABC,以及n个数,问你在(B,C)之间的数有多少个. 题解:对于每个数判断一下就好了嘛 x,y,z = map(int,i ...

  6. Codeforces Round #247 (Div. 2) ABC

    Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/Wa ...

  7. Codeforces Round #313 (Div. 2) ABC

    A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int ...

  8. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!

    Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...

  9. Codeforces Round #312 (Div. 2) ABC题解

    [比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...

随机推荐

  1. 吴裕雄 PYTHON 人工智能——基于MASK_RCNN目标检测(4)

    import os import sys import random import math import re import time import numpy as np import tenso ...

  2. dp饭卡

    电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够).所以大家 ...

  3. vue项目打包后运行报错400如何解决

    昨天一个Vue项目打包后,今天测试,发现无论localhost还是服务器上都运行不了,报错如下: Failed to load resource: the server responded with ...

  4. SpringBoot基于数据库的定时任务实现

    在我们平时开发的项目中,定时任务基本属于必不可少的功能,那大家都是怎么做的呢?但我知道的大多都是静态定时任务实现. 基于注解来创建定时任务非常简单,只需几行代码便可完成.实现如下: @Configur ...

  5. Python - 八大排序算法

    1.序言 本文使用Python实现了一些常用的排序方法.文章结构如下: 1.直接插入排序 2.希尔排序 3.冒泡排序 4.快速排序 5.简单选择排序 6.堆排序 7.归并排序 8.基数排序 上述所有的 ...

  6. 【代码审计】VAuditDemo 后台登录功能验证码绕过

    在 admin/logCheck.php中 $_POST['user']和$_POST['pass'] 未经过任何过滤或者编码处理就传入到$query中,可能存在万能密码绕过机制 但是$pass经过了 ...

  7. Hibernate学习过程出现的问题

    1  核心配置文件hibernate.cfg.xml添加了约束但是无法自动获取属性值 解决方案:手动将DTD文件导入 步骤:倒开Eclipse,找到[window]->[preference]- ...

  8. 无线客户端掉线(Disassociate and DeleteReason)

  9. UI UED设计

    Element: https://element.eleme.cn/#/zh-CN/guide/design

  10. Codeforces Round #600 (Div. 2) - B. Silly Mistake(模拟)

    题意:有一个公司,每天有员工进出,$a[i]>0$时表示$a[i]$这个员工进入公司,$a[i]<0$时表示$-a[i]$这个员工出公司,公司对进出办公室有一些严格的规定 员工每天最多只能 ...