当前位置:网站首页>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
边栏推荐
- Kibana search syntax
- Integers have friends interval GCD + double pointer
- Definition of C class and method
- Complete example demonstration of creating table to page - joint table query
- 电机与拖动(戚金清版)学习整理
- Detection technology and principle
- Framework analysis 2 Source code - login authentication
- Linear algebra Chapter 1 - determinant
- Miscellaneous 1
- 2. Devops sonar installation
猜你喜欢
[leetcode 202] happy number
Chapter 4 of line generation - linear correlation of vector systems
Class loading and classloader understanding
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
Fundamentals of in-depth learning -- a simple understanding of meta learning (from Li Hongyi's course notes)
In depth understanding of the relationship between dncblevel and noise denoising in the paper
線性代數第二章-矩陣及其運算
-- SQL query and return limit rows
Export of data
Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
随机推荐
Supply chain service terms
Contrôle automatique (version Han min)
Three ways to create threads
Type conversion in C #
Substring Inversion (Easy Version)
Database - sorting data
Export of data
Implementation of displaying database pictures to browser tables based on thymeleaf
Introduction to virtualization features
LockSupport. Park and unpark, wait and notify
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
程序设计训练
Addition, deletion, query and modification of data
Understanding and use of tp50, tp90 and tp99
Fact final variable and final variable
Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
JDBC connection database
Stability building best practices
Understanding and installing MySQL
JDBC operation transaction