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. Springmvc-crud-01错误

    错误:无法显示图书列表内容 原因:获取存储域对象中的名字写错了 controller层: 前端页面: 解决方案:前后端的代码要保持一致(名字自己定义),写代码要细心 修改成功后的界面

  2. rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TL_C_CONS_ExtendController':

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TL_ ...

  3. markdown列表

    Markdown 列表 Markdown 支持有序列表和无序列表. 无序列表使用星号(*).加号(+)或是减号(-)作为列表标记: * 第一项 * 第二项 * 第三项 + 第一项 + 第二项 + 第三 ...

  4. java中4种常用线程池

    一.线程池 线程池:说白了,就是一种线程使用模式.线程过多会带来调度开销,进而影响整体性能.而线程池维护着多个线程,等待着监督管理者分配可并发执行的任务,这避免了在处理短时间任务时创建与销毁线程的代价 ...

  5. php mongdb driver 1.17

    Installation To build and install the driver: $ pecl install mongodb $ echo "extension=mongodb. ...

  6. 我的 Python 编码规范

    python 文件的组成 为了便于描述,先上一个 demo #!/usr/bin/env python # -*- coding: utf-8 -*- """通常这里是关 ...

  7. WLC开机卡在launching....(变砖)

    1.出现故障的原因:A.通过手动更换镜像导致Boot Loader Menu Run primary image (7.0.220.0) - ActiveRun backup image (7.0.2 ...

  8. 为什么ISR4K、ASR1K等设备的QoS ACL没有显示计数?

    思科的ISR4K和ASR1K设备都是IOS XE的架构,它们和传统的IOS架构是不一样的. 以ISR4K为例,和一般的IOS(例如ISR G2)有所区别,他的转发更依赖硬件完成,针对NAT或QoS应用 ...

  9. HtmlUnit-API的使用就介绍

    转自:https://www.cnblogs.com/luotinghao/p/3800054.html 网络爬虫第一个要面临的问题,就是如何抓取网页,抓取其实很容易,没你想的那么复杂,一个开源Htm ...

  10. centos7使用docker制作tomcat本地镜像

    1.安装Docker 安装docker前请确认当前linux的内核版必须是3.10及以上 命令: uname  -r 1).yum install -y yum-utils device-mapper ...