首页 > 其他分享 >Competitive Programmer

Competitive Programmer

时间:2024-10-04 20:18:41浏览次数:3  
标签:number Competitive example 60 Bob include Programmer red

Competitive Programmer

题面翻译

给出 n n n个数,问对于每个数,是否可以将这个数的数位重新组合(可以有前导零),使其可以被 60 60 60整除,若可以,则输出 r e d red red,否则,输出 c y a n cyan cyan

题目描述

Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked $ n $ of them how much effort they needed to reach red.

“Oh, I just spent $ x_i $ hours solving problems”, said the $ i $ -th of them.

Bob wants to train his math skills, so for each answer he wrote down the number of minutes ( $ 60 \cdot x_i $ ), thanked the grandmasters and went home. Bob could write numbers with leading zeroes — for example, if some grandmaster answered that he had spent $ 2 $ hours, Bob could write $ 000120 $ instead of $ 120 $ .

Alice wanted to tease Bob and so she took the numbers Bob wrote down, and for each of them she did one of the following independently:

  • rearranged its digits, or
  • wrote a random number.

This way, Alice generated $ n $ numbers, denoted $ y_1 $ , …, $ y_n $ .

For each of the numbers, help Bob determine whether $ y_i $ can be a permutation of a number divisible by $ 60 $ (possibly with leading zeroes).

输入格式

The first line contains a single integer $ n $ ( $ 1 \leq n \leq 418 $ ) — the number of grandmasters Bob asked.

Then $ n $ lines follow, the $ i $ -th of which contains a single integer $ y_i $ — the number that Alice wrote down.

Each of these numbers has between $ 2 $ and $ 100 $ digits ‘0’ through ‘9’. They can contain leading zeroes.

输出格式

Output $ n $ lines.

For each $ i $ , output the following. If it is possible to rearrange the digits of $ y_i $ such that the resulting number is divisible by $ 60 $ , output “red” (quotes for clarity). Otherwise, output “cyan”.

样例 #1

样例输入 #1

6
603
006
205
228
1053
0000000000000000000000000000000000000000000000

样例输出 #1

red
red
cyan
cyan
cyan
red

提示说明

In the first example, there is one rearrangement that yields a number divisible by $ 60 $ , and that is $ 360 $ .

In the second example, there are two solutions. One is $ 060 $ and the second is $ 600 $ .

In the third example, there are $ 6 $ possible rearrangments: $ 025 $ , $ 052 $ , $ 205 $ , $ 250 $ , $ 502 $ , $ 520 $ . None of these numbers is divisible by $ 60 $ .

In the fourth example, there are $ 3 $ rearrangements: $ 228 $ , $ 282 $ , $ 822 $ .

In the fifth example, none of the $ 24 $ rearrangements result in a number divisible by $ 60 $ .

In the sixth example, note that $ 000\dots0 $ is a valid solution.

代码内容

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve()
{
    string s;
    cin>>s;

    ll op=0,sum=0,cnt=0;
    for(auto &t:s)
    {
        if(t=='0') op=1;
        if((t-'0')%2==0) cnt++;
        sum+=t-'0';
    }
    cnt--;

    if(op&&sum%3==0&&cnt) cout<<"red"<<endl;
    else cout<<"cyan"<<endl;
}

int main()
{
    ll t;
    cin>>t;

    while(t--) solve();

    return 0;
}

标签:number,Competitive,example,60,Bob,include,Programmer,red
From: https://blog.csdn.net/2301_80065123/article/details/142675928

相关文章

  • 【ARM】v8架构programmer guide(2)_处理器及V8基础
    目录2.1ARMv8-A3.ARMv8的基础普通世界(Non-securestate)的特权组件:安全世界(Securestate)的特权组件:安全监视器(SecureMonitor):3.1executionstates执行状态3.2改变异常级别3.3改变executionstate(执行状态)2.1ARMv8-AARMv8-A引入众多改变:3.ARMv8......
  • SciTech-EECS-EDA-Altium Designer-FTDI FT232- Xilinx JTAG Programmer + Debugger
    Origin:https://matthewtran.dev/2021/08/ftdi-xilinx-jtag-programmer/MatthewTranArticleLiterallythedaybeforestartingmysummerinternship,IdecidedtoteachmyselfhowtouseAltiumDesigner.Idecidedtotrysomethingrelativelysimpleanduseup......
  • 【efinix】 efinity Programmer里添加riscv的hex,Programner闪退
    问题在efinixefinityProgrammer里添加riscv的hex,Programner闪退分析1.某FAE提到可能hex文件有个小锁,应该是加密的问题变相解决方案使用【riscv-sapphire-ug-6.0.pdf77页】,CopyaUserBinarytoFlash(EfinityProgrammer)章节的方法,把FPGA程序和riscv的程序整合成一......
  • 【攻防世界】BadProgrammer
    BadProgrammer题目来源攻防世界NO.GFSJ0986题目描述打开网址页面如下,没有什么有用信息用dirsearch扫一下目录,发现/static../(用御剑扫不出来)其实这是一个Nginx配置错误的目录遍历漏洞,用AWVS也可以扫出来题解访问/static../查看app.js,返回以下代码constexpress=......
  • 【ARMv8/v9 GIC- 700 系列 1 -- Programmers model for GIC-700】
    请阅读【ARMGICv3/v4实战学习】文章目录GIC-700Programmersmodel寄存器实现和访问模式接口宽度和数据格式访问类型安全寄存器访问地址映射和页面GIC-700RegistermappagesSummaryGIC-700ProgrammersmodelGIC-700是ARM的一种通用中断......
  • 045篇 - 程序员提示词(Prompts for Programmers)
    大家好,我是元壤教育的张涛,一名知识博主,专注于生成式人工智能(AIGC)各领域的研究与实践。我喜欢用简单的方法,帮助大家轻松掌握AIGC应用技术。我的愿景是通过我的文章和教程,帮助1000万人学好AIGC,用好AIGC。在这一章中,我们将探讨程序员如何通过提示词工程利用ChatGPT的力量。C......
  • Using Orange Pi One as an SPI programmer with flashrom
    UsingOrangePiOneasanSPIprogrammerwithflashrom30October2019#linux#orangepi#flashromThat'squitesimple.IwasusingArmbianBusterwith4.19.62-sunxikernel.Youneedtoenablethe spi-spidev overlay,whichyoucandobyusing armbian-......
  • Sublime txt - CompetitiveProgrammingParser配置
    官网依赖环境:python3浏览器插件:CompetitiveCompanionSublmieText插件:FastOlympicCoding配置打开浏览器的扩展找到扩展CompetitiveCompanion点击详情信息找到并点击扩展选项在Customports填入12345打开SublimeText在首选项......
  • Tenka1 Programmer Contest 2019
    C-Stones枚举分界点爆算即可。#include<iostream>#include<cstdio>usingnamespacestd;constintN=200005;intn;chars[N];intsum[N][2];intmain(){ scanf("%d",&n); scanf("%s",s+1); sum[0][0]=sum[0][1]=0; for(inti=1;i......
  • Competitive Programmer 题解
    题目传送门一道模拟题。纯模拟肯定不行,考虑优化。\(60=2^2\times3\times5\),也就是说我们判断组合后的数字能否被\(2\),\(3\),\(10\)整除即可。如果这个数能被\(2\)整除,那么原数一定会存在偶数;如果这个数能被\(3\)整除,那么它的数字和应该也能被\(3\)整除;如果这个数......