Python
def PointCheck(m, f, r):
if m==-1 and f==-1 and r==-1:
return 'End'
elif m==-1 or f==-1:
return 'F'
if m==-1:
m=0
if f==-1:
f=0
if m+f>=80:
return 'A'
elif m+f>=65:
return 'B'
elif m+f>=50:
return 'C'
elif m+f>=30 and r>=50:
return 'C'
elif m+f>=30:
return 'D'
else:
return 'F'
while True:
m, f, r = list(map(int, input().split()))
ans = PointCheck(m, f, r)
if ans == "End":
break
print(ans)
Python
while True:
n, x = list(map(int, input().split()))
if n==0 and x==0:
break
ans=0
for i in range(1, n-1):
for j in range(i+1, n):
for k in range(j+1, n+1):
if x == i+j+k:
ans+=1
print(ans)
Python
r, c = list(map(int, input().split()))
field = [[0 for i in range(c)] for j in range(r)]
ans = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(0, r):
field[i] = list(map(int, input().split()))
for j in range(0, c):
ans[i][j] = field[i][j]
ans[r][j] += field[i][j]
for i in range(0, r+1):
for j in range(0, c+1):
if j<c:
print(f"{ans[i][j]} ", end='')
elif j==c:
print(f"{sum(ans[i])}")
Python
n, m, l = list(map(int, input().split()))
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(0, n):
a[i] = list(map(int, input().split()))
for i in range(0, m):
b[i] = list(map(int, input().split()))
for i in range(0, n):
for j in range(0, l):
ans = 0
for k in range(0, m):
ans += a[i][k] * b[k][j]
c[i][j] = ans
for i in range(0, n):
for j in range(0, l):
if j < l-1:
print(f"{c[i][j]} ", end='')
elif j == l-1:
print(f"{c[i][j]}")
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cctype>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
using namespace std;
using ll =long long;
using P = pair<int,int>;
int main(int argc, const char * argv[]) {
string s;
getline(cin , s);
string ans="";
rep(i, s.length()){
if(isalpha(s[i])){
if(islower(s[i])) ans += toupper(s[i]);
else if(isupper(s[i])) ans += tolower(s[i]);
}else{
ans+=s[i];
}
}
cout << ans << endl;
return 0;
}
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cctype>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
using namespace std;
using ll =long long;
using P = pair<int,int>;
int main(int argc, const char * argv[]) {
while(true){
string s;
cin >> s;
if(s=="0") break;
int ans=0;
rep(i, s.length()){
ans += s[i] - '0';
}
cout << ans << endl;
}
return 0;
}
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cctype>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
using namespace std;
using ll =long long;
using P = pair<int,int>;
int main(int argc, const char * argv[]) {
int counter[26] = {0};
char ch;
while(cin >> ch){
if(isalpha(ch)){
ch = tolower(ch);
counter[ch - 'a']++;
}
}
rep(i, 26){
cout << static_cast<char>('a'+i) << " : " << counter[i] << endl;
}
return 0;
}
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cctype>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
using namespace std;
using ll =long long;
using P = pair<int,int>;
int main(int argc, const char * argv[]) {
string s,p;
cin >> s >> p;
s = s + s;
if(s.find(p) != string::npos) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
Recommended Posts