Hiển thị các bài đăng có nhãn supereasy. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn supereasy. Hiển thị tất cả bài đăng

Thứ Ba, 8 tháng 1, 2019

UVa 12577 - Haji-e-Akbar (straightforward)

Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=441&page=show_problem&problem=4022
Sol:
#include <cstdio>
int main()
{
char input[20];
scanf("%s", input);
for (int t = 1; input[0] != '*'; ++t, scanf("%s", input))
{
if (input[0] == 'H')
printf("Case %d: Hajj-e-Akbar\n", t);
else
printf("Case %d: Hajj-e-Asghar\n", t);
}
}

UVa 12403 - Save Setu (straightforward)

Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3834
Sol:
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
int tc, x;
long long sum = 0;
char s[20];
scanf("%d", &tc);
while (tc--) {
scanf("%s", s);
if (strcmp(s, "donate") == 0) {
scanf("%d", &x);
sum += x;
} else {
printf("%lld\n", sum);
}
}
return 0;
}

UVa 12372 - Packing for Holiday (just check if all L,W,H <= 20)

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=278&page=show_problem&problem=3794
Sol:
#include <cstdio>
using namespace std;
int main() {
int cnt = 1, tc;
int l,w,h;
scanf("%d",&tc);
while(tc--){
scanf("%d %d %d",&l,&w,&h);
printf("Case %d: ",cnt++);
if(l<=20 && w<=20 && h<=20) printf("good\n");
else printf("bad\n");
}
return 0;
}

UVa 12289 - One-Two-Three (just use if-else statements)

Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=244&page=show_problem&problem=3710
Sol:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int T;
string temp;
cin >> T;
while (T--)
{
cin >> temp;
if (temp.length() == 5)
cout << "3\n";
else
{
int oneCorrect(0);
if (temp[0] == 'o')
++oneCorrect;
if (temp[1] == 'n')
++oneCorrect;
if (temp[2] == 'e')
++oneCorrect;
if (oneCorrect >= 2)
cout << "1\n";
else
cout << "2\n";
}
}
}

UVa 12279 - Emoogle Balance( simple linear scan)

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=244&page=show_problem&problem=3431
Sol:
#include <cstdio>
using namespace std;
int main() {
int n, count = 0;
while (scanf("%d", &n), n) {
count++;
int sum = 0, t;
for (int i = 0; i < n; i++) {
scanf("%d", &t);
if (t > 0)
sum++;
else
sum--;
}
printf("Case %d: %d\n", count, sum);
}
return 0;
}

Bài G - Educatioal Round 62

Đề bài: Bạn được cho 1 đồ thị vô hướng đặc biệt. Nó bao gồm $2n$ đỉnh được đánh số từ 1 đến 2n. Dưới đây là một số đặc tính của đồ thị: + ...