A
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
vector<long long>arr(n+1);
for(int i = 1;i<=n;i++){
cin>>arr[i];
}
vector<long long>pre(n+1,0);
for(int i=1;i<=n;i++){
pre[i]=pre[i-1]+arr[i];
}
while(m--){
int l,r;
cin>>l>>r;
cout << pre[r]-pre[l-1]<<endl;
}return 0;
}
B
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n,a;
cin>>n>>a;
long long int tmp,S=LLONG_MIN;
for(int i=2;i<=n;i++){
cin>>tmp;
if(tmp-a>S) S=tmp-a;
if(tmp<a) a=tmp;
}
cout<<S;
return 0;
}
C
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int a,b,c;
cin >> a >> b >> c ;
int s;
s=c%a;
int t=c-s;
int u=t/a;
cout<<u;
return 0;
}
D
#include<bits/stdc++.h>
using namespace std;
long long gcd(long a,long b){
return b == 0 ? a : gcd(b,a%b);
}
int main(){
ios::sync_with_stdio(0);
long long a,b,c;
cin>>a>>b;
long long t=a/gcd(a,b)*b;
cout<<t<<endl;
return 0;
}
E
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
long long n,m;
cin>>n>>m;
if(m*n%2==0) cout<<"yukari";
else cout<<"akai";
return 0;
}
F
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n,m;
cin>>n;
if(n ==2) cout<<7;
else {
cout<<3;
}
return 0;
}
G
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int z;
cin>>z;
if(z<=2) cout<<"NO"<<endl;
else{
cout<<"YES"<<endl;
cout<<1<<" "<<z-1<<endl;
}
return 0;
}
H
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int z;
cin>>z;
if(z<=2) cout<<"NO"<<endl;
else{
cout<<"YES"<<endl;
cout<<1<<" "<<z-1<<endl;
}
return 0;
}
I
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
long long x,y,z;
cin>>x>>y>>z;
if(x<y) swap(x,y);
if(x<z) swap(x,z);
if(y<z) swap(y,z);
if(x>=y+z) cout<<x;
if(y+z>x) cout<<y+z;
return 0;
}
J
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
long long n;
cin>>n
int a,b;
if(n%10==0) cout<<0;
else{
a=n%10;
b=10-a;
cout<<b;
}
return 0;
}
K
include<stdio.h>
int main(){
printf(" ** \n");
printf(" ** \n");
printf("************\n");
printf("************\n");
printf(" * * \n");
printf(" * * \n");
return 0;
}
L
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
cout<<j<<"*"<<i<<"="<<setw(2)<<i*j;
if(j<i) cout<<" ";
}
cout<<endl;
}
return 0;
}
M
#include<bits/stdc++.h>
using namespace std;
int main(){
doule a,b,c;
scanf("%lf %lf %lf",&a,&b,&c);
double s=(a+b+c)/3;
printf("%.2lf %.2lf",a+b+c,s);
return 0;
}
N
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int a,b,c;
double d,e,f;
cin>>a>>b>>c;
d=sqrt(a*b/c);
e=sqrt(a*c/b);
f=sqrt(b*c/a);
cout<<round((e+d+f)*4);
return 0;
}
O
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n,x,y;
cin>>n>>x>>y;
int min,max;
if(x+y>n) min=abs(x+y-n);
else min=0;
if(x>y) max=y;
else max=x;
cout<<max<<" "<<min;
return 0;
}
P
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
scanf("%d %d",&a,&b);
if(a<b) printf("<");
if(a==b) printf("=");
if(a>b) printf(">");
return 0;
}
Q
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n;
cin>>n;
if(n%2==0) cout<<n/2;
else cout<<3*n+1;
return 0;
}
R
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n;
cin>>n;
int a=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cout<<setw(4)<<a;
a++;
}
cout<<endl;
}
return 0;
}
S
#include<bits/stdc++.h>
using namespace std;
int arr[30];
int main(){
int n;
cin>>n;
arr[1] = 0;
arr[2] = 1;
arr[3] = 1;
for(int i=4;i<=25;i++){
arr[i]=arr[i-3]+2*arr[i-2]+arr[i-1];
}
cout<<arr[n];
return 0;
}
T
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int T;
cin>>T;
for(int i=1;i<=T;i++){
int a,b;
cin >> a >> b;
cout<<a+b<<endl;
}
return 0;
}
U
#include<bits/stdc++.h>
using namespace std;
int isPrime(int n){
if(n<2) return false;
for(int i=2;i*i<=n;i++){
if(n%i==0) return false;
}return true;
}
int main(){
ios::sync_with_stdio(0);
int T,n;
cin>>T;
for(int i=1;i<=T;i++){
cin>>n;
if(isPrime(n)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
V
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
long long n,p;
cin>>p;
n=llabs(p);
int sum = 0,tmp;
while(n!=0){
tmp=n%10;
n/=10;
sum+=tmp;
}
cout<<sum;
return 0;
}
W
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n,k,m;
cin >> n >> k >> m;
int f=0;
for(int i=1;i<n;i++){
f=(f+m)%i;
}
cout<<(f+k)%n;
return 0;
}
X
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int n;
cin>>n;
vector<vector<int>>arr(n);
for(int i=0;i<n;i++){
arr[i].resize(n+1);
arr[i][0] = 1;
arr[i][i] = 1;
for(int j=1;j<i;j++){
arr[i][j] = arr[i-1][j] + arr[i-1][j-1];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
cout<<arr[i][j];
if(j<i) cout<<" ";
}
cout<<endl;
}
return 0;
}

京公网安备 11010502036488号