読者です 読者をやめる 読者になる 読者になる

夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

トレーニング

実際にやってみた。

/*
ID: fujiyou1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
typedef long long ll;

int main() {
    ofstream fout ("ride.out");
    ifstream fin ("ride.in");
    string comet, group;
    fin >> comet >> group;
    ll c=1,g=1;
    for (int i=0; i<comet.length(); i++) c *= (comet[i]-'A'+1);
    for (int i=0; i<group.length(); i++) g *= (group[i]-'A'+1);
    if (c%47==g%47) fout << "GO" << endl;
    else fout << "STAY" << endl;
    return 0;
}
/*
ID: fujiyou1
PROG: gift1
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
    ofstream fout ("gift1.out");
    ifstream fin ("gift1.in");
    int np;
    string in;
    map<string, int> p, d;
    vector<string> name;
    fin >> np;
    for (int i=0; i<np; i++) {
        fin >> in;
        p[in]=0;
        d[in]=0;
        name.push_back(in);
    }
    while (fin >> in) {
        int a, n; fin >> a >> n;
        if (n!=0) {
            d[in] += a/n*n;
            for (int i=0; i<n; i++) {
                fin >> in;
                p[in] += a/n;
            }
        }
    }
    for (int i=0; i<np; i++) fout << name[i] << " " << p[name[i]]-d[name[i]] << endl;
    return 0;
}
/*
ID: fujiyou1
PROG: friday
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
    ofstream fout ("friday.out");
    ifstream fin ("friday.in");
    int n, now=0;
    int norm[] = {31,28,31,30,31,30,31,31,30,31,30,31}, leap[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int res[] = {1,0,0,0,0,0,0};
    fin >> n;
    for (int i=1900; i<1900+n; i++) {
        if (i%400==0||(i%100!=0&&i%4==0)) {
            for (int j=0; j<12; j++) {
                now = (now+leap[j]%7)%7;
                if (i!=1900+n-1||j!=11) res[now]++;
            }
        } else {
            for (int j=0; j<12; j++) {
                now = (now+norm[j]%7)%7;
                if (i!=1900+n-1||j!=11) res[now]++;
            }
        }
    }
    for (int i=0; i<6; i++) fout << res[i] << " ";
    fout << res[6] << endl;
    return 0;
}
/*
ID: fujiyou1
PROG: beads
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    ofstream fout ("beads.out");
    ifstream fin ("beads.in");
    int n, res=0; string b;
    fin >> n >> b;
    b += b;
    int next=0, now=0;
    char f,s;
    while (now<n) {
        f=b[now];
        int cnt=0;
        if (f=='w') {
            while (b[now]=='w') {
                now++; cnt++;
            }
            f=b[now];
        }
        while (b[now]==f||b[now]=='w') {
            now++; cnt++;
        }
        next=now;
        if (b[next-1]=='w') {
            next--;
            while (b[next]=='w'&&next>=0) next--;
            next++;
        }
        s=b[now];
        while (b[now]==s||b[now]=='w') {
            now++; cnt++;
        }
        //cout << cnt << b[next] << next << endl;
        now=next;
        res=max(res,cnt);
    }
    if (res>n) res=n;
    fout << res << endl;
    return 0;
}

異常

広告を非表示にする