--- 題型 ---
放剩下 相關的題目 ψ(._. )>
/*
* zerojudge
* a004. 文文的求婚
* C++
* AC (8ms, 312KB)
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin >> n){
if( (n%4==0 && n%100!=0) || n%400==0){
cout << "閏年" << endl;
}else{
cout << "平年" << endl;
}
}
return 0;
}
/*
* zerojudge
* a005. Eva 的回家作業
* C++
* AC (2ms, 292KB)
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i=0;i<n;i++){
int a,b,c,d;
int e=0;
cin >> a >> b >> c >> d;
if( (b/a)==(c/b) && (c/b)==(d/c) ){
e=d*(b/a);
}else if( (b-a)==(c-b) && (c-b)==(d-c) ){
e=d+(b-a);
}
cout << a << " " << b << " " << c << " " << d << " " << e << endl;
}
return 0;
}
/*
* zerojudge
* a006. 一元二次方程式
* C++
* AC (2ms, 332KB)
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
if(b*b-4*a*c <0){
cout << "No real root" << endl;
}else{
int x1= (-1*b+sqrt(b*b-4*a*c) ) / (2*a);
int x2= (-1*b-sqrt(b*b-4*a*c) ) / (2*a);
//
if(x1!=x2){
cout << "Two different roots x1=" << x1 << " , x2=" << x2 << endl;
}else{
cout << "Two same roots x=" << x1 << endl;
}
}
return 0;
}
/*
* codeforces
* B. Napoleon Cake
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
bool x[n];
for(int i=0;i<n;++i){
int a;
cin >> a;
x[i]=0;
for(int j=i;j>i-a;--j){
if(j<0){
break;
}else{
x[j]+=1;
}
}
}
for(int i=0;i<n;++i){
cout << x[i];
}
cout << endl;
}
}
/*
* zerojudge
* k026. 中位數
*/
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
return a<b;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int n;
cin >> n;
int arr[n];
for(int i=0;i<n;++i){
cin >> arr[i];
}
if(n%2==1){
cout << arr[n/2] << endl;
}else if(n%2==0){
cout << (arr[n/2-1]+arr[n/2])/2 << endl;
}
}
/*
* ASOJ
* 電車難題 (Metro)
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,p,m,k,d;
cin >> n >> p >> m >> k >> d;
int sit = p>n ? n : p;
int stand = p>n ? p-n : 0;
int stand2 = stand-k;
int sit2 = n-(sit-m+stand2);
if(sit2>=d){
cout << "Happy :>" << endl;
cout << sit2-d << endl;
}else{
cout << "Sad :((" << endl;
cout << (d-1)-sit2 << endl;
}
}
/*
* ASOJ
* 氧化還原滴定 (Redox titration)
*/
#include<bits/stdc++.h>
using namespace std;
/* 概念
2*(C1*V1) = 5*(C2*V2)
*/
int main(){
int C1,C2,V1,V2;
cin >> C1 >> C2 >> V1 >> V2;
if(2*C1*V1 == 5*C2*V2)){
cout << "Yes" << endl;
cout << 2*C1*V1 << endl;
}
}
/*
* zerojudge
* h026. 202001_1 猜拳
*/
#include<bits/stdc++.h>
using namespace std;
int cnt = 0;
int isWin(int n,int m){
cnt+=1;
cout << n << " ";
if(n==m){
return 0;
}else{
if(n==0 && m==2){
cout << ": Won at round " << cnt;
return 1;
}
if(n==2 && m==5){
cout << ": Won at round " << cnt;
return 1;
}
if(n==5 && m==0){
cout << ": Won at round " << cnt;
return 1;
}
}
cout << ": Lost at round " << cnt;
return -1;
}
int main(){
int f;cin >> f;
int n;cin >> n;
vector<int>arr;
for(int i=0;i<n;++i){
int x;cin >> x;
arr.push_back(x);
}
bool key = false;
for(int i=0;i<arr.size();++i){
if(i>1){
if(arr[i-2]==arr[i-1]){
if(arr[i-1]==0){
f = 5;
}else if(arr[i-1]==2){
f = 0;
}else if(arr[i-1]==5){
f = 2;
}
}else{
f = arr[i-1];
}
}else if(i>0){
f = arr[i-1];
}
//
int result = isWin(f,arr[i]);
if(result == 1 || result == -1){
key = true;
break;
}
}
if(!key){
cout << ": Drew at round " << n;
}
}
/*
Sprout OJ
2024算法班入芽考_pA
*/
#include<bits/stdc++.h>
using namespace std;
int ans = 0;
int main(){
int n,m,r,c;cin >> n >> m >> r >> c;
int nr = r,nc = c;
vector<vector<int>> v;
v.resize(n+1, vector<int>(m+1));
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
cin >> v[i][j];
}
}
//
int t;cin >> t;
string s;cin >> s;
//
for(int i=0;i<s.size();++i){
//
if(s[i]=='U'){
nr=r-1;
}else if(s[i]=='D'){
nr=r+1;
}else if(s[i]=='L'){
nc=c-1;
}else if(s[i]=='R'){
nc=c+1;
}
bool dontMove = false;
if( !(nr>=1 && nr<=n) ){
dontMove = true;
}else if( !(nc>=1 && nc<=m) ){
dontMove = true;
}else if(v[nr][nc] == -1){
dontMove = true;
}
if(dontMove){
nr=r;
nc=c;
}else{
r=nr;
c=nc;
ans += v[r][c];
if(v[r][c]>0){
v[r][c] = 0;
}
}
}
cout << ans << endl;
return 0;
}
/*
TIOJ
1004 . 猶太人敢死隊問題
*/
#include<bits/stdc++.h>
using namespace std;
#define jing_an ios_base::sync_with_stdio(0);cin.tie(0)
int main(){
jing_an;
int n;cin>>n;
int sum = 0;
for(int i=2;i<=n;++i){
sum = (sum+2)%i;
}
cout << sum + 1 << endl;
}
Last updated
Was this helpful?