【CPE】一顆星選集(Part 5) | C++

更新 發佈閱讀 6 分鐘

TeX Quotes

題目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=4&page=show_problem&problem=208

中文題目:https://zerojudge.tw/ShowProblem?problemid=c007

#include <iostream>
using namespace std;

string s;
int cnt, blk;

int main() {
while (getline(cin, s)) {
for (int i=0; i<s.length(); i++) {
if (s[i] == '\"') {
if (cnt % 2 == 0) cout << "``";
else cout << "''";
cnt++;
}
else cout << s[i];
}
cout << "\n";
}
return 0;
}

A - Doom's Day Algorithm

題目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=242&page=show_problem&problem=3170

#include <iostream>
using namespace std;
int doom[13] = {-1, 10, 21, 7, 4, 9, 6, 11, 8, 5, 10, 7, 12};
string date[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main() {
int T, m, d;
cin >> T;
while (T--) {
cin >> m >> d;
int delta = (d - doom[m]) % 7;
if (delta >= 0) {
cout << date[delta] << "\n";
} else {
cout << date[7 + delta] << "\n";
}
}
return 0;
}

Jolly Jumpers

題目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979

中文題目:https://zerojudge.tw/ShowProblem?problemid=d097

#include <iostream>
#include <cstring>
using namespace std;

int main() {
int n;
while (cin >> n) {
int pre, now;
int d[n];
for (int i=0; i<n; i++) {
d[i] = 0;
}
cin >> pre;
for (int i=1; i<n; i++) {
cin >> now;
d[abs(now - pre)]++;
pre = now;
}
bool flag = true;
for (int i=1; i<n; i++) {
if (d[i] != 1) {
flag = false;
break;
}
}
if (flag) cout << "Jolly\n";
else cout << "Not Jolly\n";
}
return 0;
}


留言
avatar-img
留言分享你的想法!
avatar-img
Jim的沙龍
1會員
31內容數
Jim的沙龍的其他內容
2025/08/13
Problem J: Summing Digits 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2307#google_vign
2025/08/13
Problem J: Summing Digits 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2307#google_vign
2025/08/13
List of Conquests 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1361 #include <iostream
2025/08/13
List of Conquests 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1361 #include <iostream
2025/08/13
The 3n + 1 problem 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=36#google_vignette 中文題目
2025/08/13
The 3n + 1 problem 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=36#google_vignette 中文題目
看更多