Educational Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer
題解
題目大意 讓你找到最小的能被d整除且不在[l, r]範圍內的數字
考慮小於l的情況 最小為d 大於r的情況 (r/d+1)*d第一個大於r的d的倍數
AC程式碼
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
//freopen("C:/input.txt", "r", stdin);
#endif
int T;
cin >> T;
while (T--)
{
ll l, r, d;
cin >> l >> r >> d;
if (d < l)
cout << d << endl;
else
cout << (r / d + 1) * d << endl;
}
return 0;
}
相關推薦
Educational Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer
題解 題目大意 讓你找到最小的能被d整除且不在[l, r]範圍內的數字 考慮小於l的情況 最小為d 大於r的情況 (r/d+1)*d第一個大於r的d的倍數 AC程式碼 #include <stdio.h> #include <bits/stdc++.h>
Educational Codeforces Round 58 (Rated for Div. 2) (題解)
C題卡了一個小時, 又被教育場教育了... A. Minimum Integer 大意:求不在$[l,r]$範圍內的最小被$d$整除的數 模擬 #include <iostream> #define REP(i,a,n) for(int i=
Educational Codeforces Round 58 (Rated for Div. 2) D.GCD Counting(樹的直徑+gcd)
題意 思路來源 Codeforce__JuRuo 題解 將每個gcd分解素因子放入對應vector 相當於對每個素因子建了一棵樹 遍歷每個素因子的樹,尋找直徑,更新答案 注意C++11的寫法 好好學學 會省不少功夫 還有一些技巧性寫法 加油! 程式碼
Educational Codeforces Round 58 (Rated for Div. 2)(待更新)
force ont div code union ems www. ble ces get人生第七場CF! 成績:(exACM) rank AC3/7 Penalty104 rating() 題目:Educational Codeforces Round 58 (Rate
Educational Codeforces Round 58 (Rated for Div. 2) (前兩題題解)
感慨 這次比較昏迷最近演算法有點飄,都在玩pygame。。。做出第一題讓人hack了,第二題還昏迷想錯了 A Minimum Integer(數學) 水題,上來就能做出來但是讓人hack成了tle,所以要思考一下具體的過程 原本我是認為直接把d進行累加看什麼時候不在那個segment內也就是那個範圍之
Educational Codeforces Round 58 (Rated for Div. 2)
昨晚太太天真題目雖然簡單但是方法用的很蠢。。。。 A(簡單數學) #include<stdio.h> int n,l,r,p; main() { scanf("%d",&n); while(n--) { scanf("%d%d%d",&l,&r,
Educational Codeforces Round 58 (Rated for Div. 2) 題解
註意 accordion char color ces nbsp cdb 字符 bre Educational Codeforces Round 58 (Rated for Div. 2) 題目總鏈接:https://codeforces.com/contest/110
Educational Codeforces Round 58 (Rated for Div. 2) E. Polycarp's New Job
題解 題目大意 +表示增加一個矩形 ?表示查詢 設錢包能無限疊加的裝正方形問當前大小的錢包是否能把所有矩形裝入 將所給xy調整為高<寬 記錄一個最大的高度 一個最大的寬度 查詢時比較高寬即可 AC程式碼 #include <stdio.h> #include
Educational Codeforces Round 58 (Rated for Div. 2)(B. Accordion)
B. Accordion time limit per test3 seconds memory limit per test256 megabytes inputstandard input
Educational Codeforces Round 58 (Rated for Div. 2)(A. Minimum Integer)
A. Minimum Integer time limit per test:1 second memory limit per test:256 megabytes input:standard input
Educational Codeforces Round 37 (Rated for Div. 2)A,B,C,F
fine 暴力模擬 需要 lose sort codeforce 結構 分享圖片 線段樹 A Water The Garden 數據不大,暴力模擬下直至把每個花床都遍歷過的過程即可 1 #include <bits/stdc++.h> 2 us
Educational Codeforces Round 54 (Rated for Div. 2) A B C D E題解
這些題目挺有意思,起碼我都錯過,可能這兩天精力有點不足,腦子不太夠用??? A題連結:http://codeforces.com/contest/1076/problem/A 題意:給定一個字串,最多可以刪掉一個字元,使得字典序最小; 思路:首先跟原串比較的話,某一
Educational Codeforces Round 53 (Rated for Div. 2) A,B,C,D,E題解
A. Diverse Substring 題意:找一個子串滿足任何一個字元的出現次數小於 n/2 n是子串的長度, 顯然兩個不相同的字元組成的子串就是滿足情況的; #include<bits/stdc++.h> using namespace std; #d
Educational Codeforces Round 55 (Rated for Div. 2) A - Vasya and Book
傳送門 https://www.cnblogs.com/violet-acmer/p/10035971.html 題意: 一本書有n頁,每次只能翻 d 頁,問從x頁到y頁需要翻動幾次? 注意:往前翻最少翻到第1頁,往後翻最多翻到n頁。 題解: 一開始想找規律來著,emm
【浮*光】Educational Codeforces Round 51 (Rated for Div. 2) A,B,C,D 題解
最少的操作使原串變成有數字+大小寫字母的串。 #include<iostream> #include<cstdio> #include<cstring> #i
Educational Codeforces Round 51 (Rated for Div. 2).A. Vasya And Password(模擬)
A. Vasya And Password time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
Educational Codeforces Round 47 (Rated for Div. 2) A模擬 B思維 C數學 D數學,暴力
A Code: #include <bits/stdc++.h> using namespace std; const int AX = 1e3 + 66; int a[AX]; int c
Educational Codeforces Round 53 (Rated for Div. 2) A. Diverse Substring
A. Diverse Substring You are given a string ss, consisting of nn lowercase Latin letters. A substring of string ss is a continuous seg
Educational Codeforces Round 53 (Rated for Div. 2) A,B,C,D,E題解
A. Diverse Substring 題意:找一個子串滿足任何一個字元的出現次數小於 n/2 n是子串的長度, 顯然兩個不相同的字元組成的子串就是滿足情況的; #include<bits
Educational Codeforces Round 51 (Rated for Div. 2) A,B,C 題解
傳送門 A. Vasya And Password time limit per test 1 second memory limit per test 256 megabytes input standard input output standard o