当前位置:网站首页>Cf515b drazil and his happy friends
Cf515b drazil and his happy friends
2022-04-23 06:29:00 【cornivores】
CF515B Drazil and His Happy Friends
The question : Yes n A boy and m A girl , The first t Day invitation t%n Two boys and t%m Dinner with a girl , Some people are optimistic , Eating with optimistic people can make you optimistic , Ask if everyone can become optimistic in a few days .
solution : Just direct violence , When I first thought of it, I always WA, Later I thought of , If the people behind are optimistic , Cycle only n*m Can't update to the person in front this time , So choose to cycle multiple times , In the future, problems with small data must be circulated to the end 0.0
Code :
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 110;
int n, m, nn, mm;
int a[N], b[N];
int tu[N][N];
int va[N], vb[N];
int main() {
int x;
scanf("%d%d", &n, &m);
scanf("%d", &nn); while(nn--) scanf("%d", &x), a[x] = 1;
scanf("%d", &mm); while(mm--) scanf("%d", &x), b[x] = 1;
int t = 0;
for(int t = 0; t <= n*m*2; ++t) // This is it !!
if(a[t%n] || b[t%m]) a[t%n] = b[t%m] = 1;
int f = 1;
for(int i = 0; i < n; ++i) if(!a[i]) {
f = 0; break; }
for(int i = 0; i < m; ++i) if(!b[i]) {
f = 0; break; }
if(f) puts("Yes");
else puts("No");
return 0;
}
版权声明
本文为[cornivores]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210615591988.html
边栏推荐
- Busybox initrd and initialization process
- ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
- JDBC operation transaction
- Rust 的多线程安全引用 Arc
- 7.Domino piling
- 9.Life, the Universe, and Everything
- Supply chain service terms
- Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
- ThreadLocal. Threadlocalmap analysis
- Generation of verification code
猜你喜欢
![[leetcode 67] sum of two binary numbers](/img/91/afdd8197ca44ee910e2ee490929df1.png)
[leetcode 67] sum of two binary numbers

Practical operation - Nacos installation and configuration
![Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi](/img/1b/4eea05e2634780f45b44273d2764e3.png)
Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi

Explain of MySQL optimization

Substring Inversion (Easy Version)

Preparedstatement prevents SQL injection

Explanation of login page
![[leetcode 54] spiral matrix](/img/c0/9a55a62befb783a5bfc39dc3a96cb2.png)
[leetcode 54] spiral matrix

Integration and induction of knowledge points of automatic control principle (Han min version)

Kibana search syntax
随机推荐
Kalman filter and inertial integrated navigation
Miscellaneous 1
ThreadLocal. Threadlocalmap analysis
SQL optimization best practices
Three ways to create threads
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
[leetcode 290] word rules
PHP processing JSON_ Decode() parses JSON stringify
Common sense of thread pool
Customized communication between threads (reentrantlock)
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
线程和进程的关系和区别是什么
Busybox initrd and initialization process
检测技术与原理
Robocode教程3——Robo机器剖析
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
Chapter 3 of linear algebra - Elementary Transformation of matrix and system of linear equations
Pytorch notes - complete code for linear regression & manual or automatic calculation of gradient code comparison
Database - sorting data
Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images