codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

题目链接:http://www.codeforces.com/problemset/problem/460/A
题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子,请问第几天的时候Vasya会没有袜子穿?
C++代码:

#include <iostream>
using namespace std;
int n, m;
int main()
{
    cin >> n >> m;
    int d = 0;
    while (n)
    {
        d ++;
        if (n)
            n --;
        else
            break;
        if (d % m == 0)
            n ++;
    }
    cout << d;
    return 0;
}

C++

时间: 2024-08-08 17:49:34

codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)的相关文章

codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

题目链接:http://www.codeforces.com/problemset/problem/339/A题意:重新组合加法字符串,使得按照1,2,3的顺序进行排列.C++代码: #include <iostream> #include <string> using namespace std; int cnt[3]; string s, ans = ""; int main() { cin >> s; int len = s.length();

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o

codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)

题目链接:http://www.codeforces.com/problemset/problem/131/A题意:字符串大小写转换.C++代码: #include <cstdio> #include <cstring> char s[110]; bool islow(char c) { return c >= 'a' && c <= 'z'; } char up(char c) { return c - 32; } char low(char c) {

codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)

题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cstdio> #include <cstring> int cmp(char *s, char *t) { while (*s) { if (*s <= 'Z') *s += 32; if (*t <= 'Z') *t += 32; if (*s < *t) return -1

codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)

题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n].C++代码: #include <iostream> using namespace std; int n, f[11][11]; int main() { cin >> n; for (int i=1;i<=n;i++) f[i][1] = f[1][

codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)

题目链接:http://www.codeforces.com/problemset/problem/268/A题意:足球比赛中如果主场球队的主场球衣和客队的客队球衣颜色一样,那么要求主队穿上他们的可对球衣,现在有n个球队,每一球队的主场球衣和客场球衣的颜色都告诉你了,它们两两之间要比一场赛.求其中主队穿客场球衣的比赛场数.C++代码: #include <iostream> using namespace std; const int maxn = 33; int x[maxn], y[max

codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)

题目链接:http://www.codeforces.com/problemset/problem/580/A题意:求最长连续非降子序列的长度.C++代码: #include <iostream> using namespace std; const int maxn = 100100; int n, a[maxn], tmp, ans; int main() { cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]

codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)

题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #include <iostream> using namespace std; string s; bool _in(char c, string s) { for (int i =0 ; i < s.length(); i ++) if (c == s[i]) return true; retu

codeforces水题100道 第十二题 Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division (brute force)

题目链接:http://www.codeforces.com/problemset/problem/122/A题意:判断一个数是否能被一个lucky number整除,一个lucky number是一个只包含4或7的数.C++代码: #include <cstdio> int lucky[14] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}; bool check(int x) { for (int i = 0