当前位置:网站首页>小红的删数字
小红的删数字
2022-06-12 02:19:00 【whitewall_9】
分类讨论sum%3 == 0, == 1 == 2
其中sum%3 == 0的情况可以应用到=1,等于2的情况
注意n = 1等特殊 情况的判断
还有就是小紫赢的条件是等于的时候%2==1和不等于的时候>2
重要的方法是不断枚举特例,从数量上去枚举,只有三个等价类
// Problem: 小红的删数字
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/11251/C
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// 2022-06-10 20:17:47
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> Vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const double pi = acos(-1.0);
inline ll ksc(ll x,ll y,ll mod)
{
ll ans = 0;
while (y) {
if (y & 1)
ans = (ans + x) %mod;
y >>= 1;
x = (x + x) %mod;
}
return ans;
}
inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a;
a = a * a;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
// inline ll inv (ll a) {
// return qmi(a, mod - 2);
// }
int num[5];
int n, sum;
string s;
void solve() {
cin >> s;
for (auto t : s) {
int c = t - '0';
if (c == 0) continue;
n ++;
c%=3;
num[c] ++;
sum += t -'0';
}
if (sum % 3 == 0) {
if (num[0] == 0 || n <= 1) {
puts("yukari");
return;
}
num[0] --;
n --;
if (num[0] == 0) {
if (n == 1) {
puts("kou");
return;
}
if (num[1] != num[2] && abs(num[1] - num[2]) > 1
|| (num[1] == num[2] && num[1]%2))
{
puts("yukari") ;
}
else puts("kou");
}
else {
if (num[1] != num[2])
puts("yukari");
else
{
puts("kou");
}
}
}
else if (sum % 3 == 1) {
if (num[1] == 0 || n <= 1) {
puts("yukari");
return;
}
num[1] --;
n --;
if (num[0] == 0) {
if (n == 1) {
puts("kou");
return;
}
if (num[1] != num[2] && abs(num[1] - num[2]) > 1
|| (num[1] == num[2] && num[1]%2))
{
puts("yukari") ;
}
else puts("kou");
}
else {
if (num[1] != num[2])
puts("yukari");
else
{
puts("kou");
}
}
}
else if (sum % 3==2) {
if (num[2] == 0 || n <= 1) {
puts("yukari");
return;
}
num[2] --;
n --;
if (num[0] == 0) {
if (n == 1) {
puts("kou");
return;
}
if (num[1] != num[2] && abs(num[1] - num[2]) > 1
|| (num[1] == num[2] && num[1]%2))
{
puts("yukari") ;
}
else puts("kou");
}
else {
if (num[1] != num[2])
puts("yukari");
else
{
puts("kou");
}
}
}
}
int main () {
// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
int t;
t =1;
//cin >> t;
while (t --) solve();
return 0;
}
边栏推荐
- PHP development 09 article module deletion and article classification writing
- ozzanimation-基於sse的動作系統
- 力扣解法汇总713- 乘积小于 K 的子数组
- What is SAP c/4hana Foundation
- 2022 western style pastry (technician) recurrent training question bank and online simulated examination
- 力扣解法汇总450-删除二叉搜索树中的节点
- Graduation design of fire hydrant monitoring system --- thesis (add the most comprehensive hardware circuit design - > driver design - > Alibaba cloud Internet of things construction - > Android App D
- Force deduction solution summary 824 goat Latin
- 打包一个包含手表端应用的手机端APK应用—Ticwear
- virsh创建/关闭/停止虚拟机常用的几条指令
猜你喜欢

DDD的分层架构

Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?

程序员应该如何解决买菜难问题?手把手带你利用无障碍辅助功能快速下单抢菜

UE4\UE5触摸屏touch事件:单指、双指

2022最全面的Redis事务控制(带图讲解)

The release of star ring kundb 2.2 provides a new choice for business systems with high concurrent transactions and queries

Graphical data analysis | business analysis and data mining

Proxy and reflection (II)

Implementation scheme of iteration and combination pattern for general tree structure

SQL calculates KS, AUC, IV, psi and other risk control model indicators
随机推荐
Hypergraph tilted data is merged into root node and transferred to 3dfiles
Graphic data analysis | data cleaning and pretreatment
A mystery of the end of vagrant up
力扣解法汇总699-掉落的方块
Package a mobile APK app containing watch app - ticwear
Transformation of geographical coordinates of wechat official account development
力扣解法汇总388-文件的最长绝对路径
Force deduction solution summary 668- the smallest number k in the multiplication table
力扣解法汇总398-随机数索引
力扣解法汇总965-单值二叉树
力扣解法汇总675-为高尔夫比赛砍树
BaseDexClassLoader那些事
ADB command uses JKS file to sign apk
力扣解法汇总467-环绕字符串中唯一的子字符串
virsh创建/关闭/停止虚拟机常用的几条指令
ozzanimation-基於sse的動作系統
力扣解法汇总942-增减字符串匹配
通用树形结构的迭代与组合模式实现方案
serialization and deserialization
Explore performance optimization! Performance improvement from 2 months to 4 hours!