text stringlengths 49 983k |
|---|
#include <iostream>
int main(){
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int b;
std::cin >> b;
std::cout << a[b - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int K; cin >> K;
vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << A[K-1] << "\n";
} |
#include<iostream>
using namespace std;
int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int n;
cin>>n;
cout<<a[n-1]<<endl;
return 0;
} |
#include<stdio.h>
int main()
{
int n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
scanf("%d", &k);
printf("%d", n[k-1]);
}
|
#include<bits/stdc++.h>
using namespace std;
int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
int main(){
int t ;
cin>>t;
cout<<a[t-1]<<endl;
}
|
#include<cstdio>
int main() {
int num[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int in;
scanf("%d", &in);
printf("%d\n", num[in-1]);
return 0;
} |
#include<iostream>
using namespace std;
int main(){
int K,A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>K;
cout<<A[K-1]<<endl;
} |
#include<iostream>
using namespace std;
int main()
{
int n,a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin >> n;
cout << a[n-1] << endl;
return 0;
} |
#include <iostream>
using namespace std;
int main () {
int N;
cin >> N;
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << a[N] << endl;
} |
#include<iostream>
using namespace std;
int main()
{
int k;
cin>>k;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1]<<endl;
}
|
#include<bits/stdc++.h>
using namespace std;
int a[100]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;
int main()
{
cin>>k;
cout<<a[k];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> vec = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
cin >> k;
cout << vec[k-1] << endl;
} |
#include<bits/stdc++.h>
using namespace std;
int num[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
int k;
cin >> k;
cout << num[k];
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
cin>>k;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1];
}
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
cout<<a[n-1]<<endl;
} |
#include <iostream>
using namespace std;
int main(){
int n[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
cin>>k;
cout<<n[k-1]<<endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main()
{
int s[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int n;
cin>>n;
cout<<s[n-1]<<endl;
}
|
#include <iostream>
#include <cstdio>
using namespace std;
int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,\
5,4,1,4,1,51};
int main()
{
int k;
cin>>k;
cout<<a[k-1];
return 0;
} |
#include <iostream>
using namespace std;
int main(){
int k = 0;
cin>>k;
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1];
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin >>n;
cout << a[n-1];
} |
#include<bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int k;
cin>>k;
cout<<a[k-1];
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> vec;
vec={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int K;
cin>>K;
K-=1;
cout<<vec.at(K)<<endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
int k;cin>>k;
cout<<a[k-1]<<endl;
}
|
#include<iostream>
using namespace std;
int main()
{
int k;
cin>>k;
int A[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<A[k-1];
}
|
#include<iostream>
using namespace std;
int main(){
int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;cin >> n;--n;cout << A[n];
}
|
#include<iostream>
using namespace std;
int main() {
int tbl[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int K;cin>>K;
cout << tbl[K-1] << endl;
return 0;
} |
#include<iostream>
using namespace std;
int main()
{
int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin>>n;
cout<<ar[n-1];
} |
#include<cstdio>
int const a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
int main() {
scanf("%d",&k);
printf("%d",a[k-1]);
return 0;
} |
#include <iostream>
using namespace std;
int main() {
int k;
int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin >> k;
cout << arr[k-1];
} |
#include <iostream>
using namespace std;
int main(){
int p[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<p[k-1]<<endl;
} |
#include<iostream>
using namespace std;
int main(void) {
int K;
int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
cin >> K;
cout << A[K - 1];
} |
#include<iostream>
using namespace std;
int main()
{
int k,i;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>k;
cout<<a[k-1];
} |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<a.at(k-1);
} |
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int vec[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
cout << vec[n-1] << endl;
} |
#include <stdio.h>
int a[40] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int k;
int main() {
scanf("%d", &k);
printf("%d\n", a[k - 1]);
} |
#include <iostream>
using namespace std;
int len[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
int main(){
int K;
cin>>K;
cout<<len[K-1]<<endl;
} |
#include<iostream>
using namespace std;
int main(){
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<a[k];
return 0;
} |
#include<iostream>
using namespace std;
int main()
{
int K;
cin>>K;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[K-1]<<endl;
return 0;
} |
#include <cstdio>
int pi[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
int k; scanf("%d",&k);
printf("%d",pi[k-1]);
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
int N[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int K;
cin >> K;
cout << N[K-1] << endl;
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main()
{int K; cin >> K;
cout << vector<int>{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}[K - 1] << endl;} |
#include <bits/stdc++.h>
using namespace std;
int main(){
int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
int n;cin>>n;
cout<<s[n-1];
} |
#include<bits/stdc++.h>
using namespace std;
int a[1001]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int k;
cin>>k;
cout<<a[k-1];
}
|
#include <iostream>
using namespace std;
int main(void){
int a[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int K;
cin >> K;
cout << a[K - 1] << endl;
}
|
#include<iostream>
using namespace std;
int main()
{
int arr[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin>>n;
cout<<arr[n]<<endl;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;
cin>>k;
cout<<n[k-1]<<endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main()
{
int t[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int a;
cin>>a;
cout<<t[a-1]<<endl;
return 0;
}
|
#include<cstdio>
int k;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
scanf("%d", &k);
printf("%d\n", a[k-1]);
}
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int n[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int a;
cin>>a;
cout<<n[a-1];
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int k;
int ar[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>k;
cout<<ar[k-1];
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k ;
cin>>k;
cout<<arr[k-1];
}
|
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int> v={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n; cin>>n;
cout<<v[n];
return 0;
} |
#include<cstdio>
int a[33]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int main()
{
int n;
scanf("%d",&n);
printf("%d",a[n]);
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int a[33]={0 ,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
int n;
cin>>n;
cout<<a[n];
}
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;cin>>k;
int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<ar[k-1];
return 0;
} |
#include<iostream>
using namespace std;
int main(){
int k;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>k;
cout<<a[k-1];
return 0;
} |
#include <iostream>
using namespace std;
int main(){
int k,r[32]={1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin >> k;
cout << r[k-1] << endl;
} |
#include<stdio.h>
int main()
{
int k;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
scanf("%d",&k);
printf("%d\n",a[k-1]);
return 0;
}
|
#include<iostream>
using namespace std;
int main()
{
int a[40]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int n;cin>>n;
cout<<a[n-1];
} |
#include<iostream>
using namespace std;
int main(){
int buf[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
cin >> k;
cout << buf[k-1];
return 0;
} |
#include<stdio.h>
int main(){
int n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
scanf("%d",&k);
printf("%d",n[k-1]);
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
signed main(){
int k;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>k;
cout<<a[k-1]<<"\n";
} |
#include <stdio.h>
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int k;
scanf("%d",&k);
printf("%d\n",a[k]);
return 0;
} |
#include<iostream>
using namespace std;
int main(){
int k;
cin>>k;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1];
} |
#include<iostream>
using namespace std;
int main ()
{
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;
cin>>k;
cout<<a[k-1];
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main(){
int S[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int K;
cin >> K;
cout << S[K-1] << endl;
return 0;
} |
#include "iostream"
using namespace std;
int main()
{
int n;
int s[] = { 0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
cin>>n;
cout << n[s];
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[33]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
cin>>k;
cout<<a[k-1]<<endl;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
int k;
cin>>k;
int s[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
cout<<s[k-1]<<endl;
return 0;
} |
#include <iostream>
using namespace std;
int K;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2,
1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
cin>>K;
cout<<a[K-1]<<endl;
} |
#include <stdio.h>
int main(void) {
int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
int n;
scanf("%d", &n);
printf("%d", arr[n-1]);
return 0;
} |
#include<iostream>
using namespace std;
int main(){
int K , ar[33]={1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>K;
cout<<K[ar];
return 0 ;
}
|
#include <iostream>
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
int K;
std::cin >> K;
std::cout << a[K-1];
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int> a={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
cin>>k;
cout<<a.at(k-1)<<endl;
} |
#include <iostream>
using namespace std;
int main()
{
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int a;cin>>a;
cout<<arr[a-1]<<endl;
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k; cin>>k;
cout<<a[k-1]<<'\n';
} |
#include<bits/stdc++.h>
using namespace std;
int ans[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int k;cin>>k;cout<<ans[k]<<endl;
} |
#include <iostream>
using namespace std;
int K;
int main() {
cin >> K;
int a[34] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << a[K] << endl;
} |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int k;
vector <int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cin>>k;
cout<<v[k-1];
} |
#include<cstdio>
using namespace std;
const int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int main()
{
int K;
scanf("%d",&K);
printf("%d\n",a[K-1]);
return 0;
} |
#include <stdio.h>
int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
int a;
scanf("%d",&a);
printf("%d",x[a-1]);
return 0;
} |
#include <iostream>
using namespace std;
int main(){
int data[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout <<data[k-1];
}
|
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int k;
scanf("%d",&k);
printf("%d\n",a[k-1]);
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int a[35]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int main()
{
int n;
cin>>n;
cout<<a[n];
return 0;
} |
#include <cstdio>
int main(){
int a[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}, k;
scanf("%d", &k);
printf("%d\n", a[k]);
} |
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
ans = (ans * a) % MOD, --b;
} return ans;
}
*/
struct st {
ll a, b;
};
const int N = 120000;
st a[N];
int n;
ll sm[N];
ll ap = 0;
ll aq = 1;
ll gcd(ll a, ll b) {
while (b) {
ll q = a % b;
a = b;
b = q;
}
return a;
}
using lll = __int128_t;
void upd(ll p, ll q) {
ll g = gcd(p, q);
p /= g, q /= g;
if (lll(ap) * q < lll(p) * aq) {
ap = p;
aq = q;
}
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(20);
cin >> n;
ll sum = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i].a >> a[i].b;
sum += a[i].a;
}
sort(a, a + n, [] (st a, st b) {
return max(a.a, a.b) > max(b.a, b.b);
});
sm[0] = 0;
for (int i = 0; i < n; ++i) {
sm[i + 1] = sm[i] + max(a[i].a, a[i].b);
}
for (int i = 0; i < n; ++i) {
int l = 0;
int r = n + 1;
while (r - l > 1) {
int m = (l + r) >> 1;
ll cur = sum - a[i].b - sm[m];
if (i < m) {
cur += max(a[i].a, a[i].b);
}
if (cur > 0) {
l = m;
} else {
r = m;
}
}
if (r <= n) {
int cnt = r;
if (i >= r) {
++cnt;
}
cnt = n - cnt;
ll cur = sum - sm[r];
if (i < r) {
cur += max(a[i].a, a[i].b);
}
if (cur <= 0) {
upd(cnt + 1, n);
} else {
assert(cur <= a[i].b);
ll p = cnt * a[i].b + a[i].b - cur;
ll q = a[i].b * n;
upd(p, q);
}
}
}
cout << ap << " " << aq << "\n";
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int a[200010],b[200010],n,val[200010],l,r,mid,ans,fp,nwp;
long long nw,sum[200010],nww,fa,fb,nwa,nwb;
long long gcd(long long a,long long b) {return (!b)?a:gcd(b,a%b);}
int main()
{
scanf("%d",&n);
for (int i=1; i<=n; i++) scanf("%d%d",&a[i],&b[i]),val[i]=max(a[i],b[i]),nw+=min(a[i]-b[i],0);
sort(val+1,val+1+n),sum[0]=0,fp=0,fa=0,fb=1;
for (int i=1; i<=n; i++) sum[i]=sum[i-1]+val[i];
for (int i=1; i<=n; i++)
{
l=1,r=n,ans=0,nww=(a[i]<b[i]?nw:nw+a[i]-b[i]);
while (l<=r)
{
mid=(l+r)>>1;
if (sum[mid]-(max(a[i],b[i])<=val[mid]?max(a[i],b[i]):0)+nww<=0) ans=mid,l=mid+1; else r=mid-1;
}
nww=nww-(a[i]-b[i])+sum[ans]-(max(a[i],b[i])<=val[ans]?max(a[i],b[i]):0);
nwp=ans-(max(a[i],b[i])<=val[ans]);
nwa=b[i]-(a[i]+nww),nwb=b[i];
if (nwp>fp||nwp==fp&&nwa*fb>nwb*fa) fp=nwp,fa=nwa,fb=nwb;
}
fa+=fp*fb,fb*=n;
long long g=gcd(fa,fb);
printf("%lld %lld\n",fa/g,fb/g);
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll nt;
vector <pair <ll, ll> > res;
ll gcd (ll a, ll b)
{
if (b == 0) return a;
return gcd (b, a % b);
}
int main()
{
ios_base::sync_with_stdio(0);
cin >> N;
nt = 0;
for (int i = 0; i < N; i++)
{
int a, b;
cin >> a >> b;
if (a < b)
{
nt += b - a;
res.push_back (make_pair (b, b));
}
else
{
res.push_back (make_pair (a, b));
}
}
sort (res.begin(), res.end());
ll shi = 0;
ll nwhole = 0;
ll nbest = 1, dbest = 1;
for (int i = 0; i < N; i++)
{
//cout << i << " " << nt << " " << res[i].first << " " << res[i].second << endl;
if (res[i].first <= nt)
{
nt -= res[i].first;
shi = max (shi, res[i].second);
nwhole++;
continue;
}
else
{
// (i * res[i] + nt) / N * res[i]
ll nnum = res[i].first - nt;
ll dnum = max (shi, res[i].second);
ll g = gcd (nnum, dnum);
nnum /= g;
dnum /= g;
if (nnum * dbest < dnum * nbest)
{
nbest = nnum;
dbest = dnum;
}
//cout << nnum / g << " " << dnum / g << "\n";
//return 0;
}
}
// (nwhole + 1 - nbest/dbest) / N
ll tnum = (nwhole + 1) * dbest - nbest;
ll tden = N * dbest;
ll g = gcd (tnum, tden);
tnum /= g;
tden /= g;
cout << tnum << " " << tden << "\n";
return 0;
} |
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100000;
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
void get(ll &a, ll &b) {
ll d = gcd(a, b);
a /= d, b /= d;
}
ll ans1, ans2;
void update(ll a, ll b) {
get(a, b);
if( 1.0*ans1/ans2 < 1.0*a/b )
ans1 = a, ans2 = b;
}
struct node{
int A, B, C;
friend bool operator < (node a, node b) {
return a.C < b.C;
}
}a[MAXN + 5];
ll sum[MAXN + 5], SA;
int main() {
int N; scanf("%d", &N);
for(int i=1;i<=N;i++)
scanf("%d%d", &a[i].A, &a[i].B), a[i].C = max(a[i].A, a[i].B);
sort(a + 1, a + N + 1);
for(int i=N;i>=1;i--)
sum[i] = sum[i + 1] + a[i].C, SA += a[i].A;
ans1 = 0, ans2 = 1;
for(int i=1;i<=N;i++) {
if( SA - (sum[1] - a[i].C) > a[i].B )
continue;
int le = 1, ri = N + 1;
while( le < ri ) {
int mid = (le + ri + 1) >> 1;
if( mid <= i ) {
if( SA - (sum[mid] - a[i].C) <= a[i].B ) le = mid;
else ri = mid - 1;
}
else {
if( SA - sum[mid] <= a[i].B ) le = mid;
else ri = mid - 1;
}
}
if( le <= i ) {
if( SA - (sum[le] - a[i].C) <= a[i].B && SA - (sum[le] - a[i].C) >= 0 )
update(1LL*le*a[i].B - (SA - (sum[le] - a[i].C)), 1LL*N*a[i].B);
}
else {
if( SA - sum[le] <= a[i].B && SA - sum[le] >= 0 )
update(1LL*(le-1)*a[i].B - (SA - sum[le]), 1LL*N*a[i].B);
}
}
printf("%lld %lld\n", ans1, ans2);
} |
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#include <bitset>
using namespace std;
#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
const int MAXBEAM=100000;
struct Beam { int a,b; int key; };
bool operator<(const Beam &p,const Beam &q) { return p.key<q.key; }
struct Frac { ll num,den; Frac():num(0),den(1) {} Frac(ll _num,ll _den) { num=_num,den=_den; ll g=gcd(num,den); num/=g; den/=g; } };
bool operator>(const Frac &p,const Frac &q) { return p.num*q.den>q.num*p.den; }
int nbeam;
Beam beam[MAXBEAM];
int nslow;
Beam slow[MAXBEAM];
int nfast;
Beam fast[MAXBEAM];
Frac solve() {
nslow=nfast=0;
REP(i,nbeam) if(beam[i].a<beam[i].b) fast[nfast++]=beam[i]; else slow[nslow++]=beam[i];
REP(i,nfast) fast[i].key=fast[i].b; sort(fast,fast+nfast);
REP(i,nslow) slow[i].key=slow[i].a; sort(slow,slow+nslow);
if(nfast==0) return Frac(0,1);
ll asum=0,bsum=0;
REP(i,nfast) asum+=fast[i].a;
int atslow=0;
for(int i=nfast-1;i>=0;--i) {
while(atslow<nslow&&bsum+fast[i].b>=asum) {
if(slow[atslow].a>=fast[i].b) break;
if(bsum+fast[i].b>=asum+slow[atslow].a) { asum+=slow[atslow++].a; continue; }
if(i==0) break;
if(slow[atslow].a>=fast[i-1].b) break;
if(bsum+fast[i].b+fast[i-1].b>=asum+slow[atslow].a) { asum+=slow[atslow++].a; continue; }
assert(false);
}
if(bsum+fast[i].b>=asum) {
int ipart=atslow+i;
Frac fpart(bsum+fast[i].b-asum,fast[i].b);
int idx=-1; REP(k,atslow) if(idx==-1||slow[k].b>slow[idx].b) idx=k;
FOR(k,atslow,nslow) {
assert(bsum+fast[i].b<asum+slow[k].a);
if(bsum+fast[i].b+slow[k].b>=asum+slow[k].a) {
Frac cpart(bsum+fast[i].b+slow[k].b-asum-slow[k].a,slow[k].b);
if(cpart>fpart) fpart=cpart;
}
if(i!=0&&bsum+fast[i].b+fast[i-1].b>=asum+slow[k].a) {
Frac cpart(bsum+fast[i].b+fast[i-1].b-asum-slow[k].a,fast[i-1].b);
if(cpart>fpart) fpart=cpart;
}
if(idx!=-1&&bsum+fast[i].b+slow[idx].b>=asum+slow[k].a) {
Frac cpart(bsum+fast[i].b+slow[idx].b-asum-slow[k].a,slow[idx].b);
if(cpart>fpart) fpart=cpart;
}
}
return Frac((ll)ipart*fpart.den+fpart.num,(ll)fpart.den*nbeam);
}
bsum+=fast[i].b;
}
assert(false); return Frac(0,1);
}
void run() {
scanf("%d",&nbeam);
REP(i,nbeam) scanf("%d%d",&beam[i].a,&beam[i].b);
Frac ans=solve();
printf("%lld %lld\n",ans.num,ans.den);
}
int main() {
run();
return 0;
}
|
#include<bits/stdc++.h>
#define a first
#define b second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
x=0; char c=getchar(); int f=1;
while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
static ui seed=416;
return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
int n,v[N];Pii s[N];
struct Frac{
ll a,b;// a/b
Frac(ll A=0,ll B=1){a=A;b=B;}
}ans;
ll gcd(ll a, ll b){return !b?a:gcd(b,a%b);}
inline Frac Norm(Frac y){
ll g=gcd(y.a,y.b);y.a/=g;y.b/=g;return y;
}
inline void upd(Frac &x, Frac y){
y=Norm(y);if(1.0*x.a/x.b>1.0*y.a/y.b)x=y;
}
bool cmp(Pii x, Pii y){return x.a+max(x.b-x.a,0)<y.a+max(y.b-y.a,0);}
bool ck(int k){
ll tot=0;rep(i,1,n)tot+=max(s[i].b-s[i].a,0);
rep(i,1,k)tot-=v[i];return tot>=0;
}
int main() {
read(n);rep(i,1,n)read(s[i].a),read(s[i].b);
sort(s+1,s+n+1,cmp);
rep(i,1,n)v[i]=s[i].a+max(s[i].b-s[i].a,0);
/*int L=0,R=n;
while(L<R){
int mid=(L+R+1)>>1;
if(ck(mid))L=mid;else R=mid-1;
}
int k=L;*/
int k=0;ll tot=0;rep(i,1,n)tot+=max(s[i].b-s[i].a,0);
while(tot-v[k+1]>=0)k++,tot-=v[k];
assert(k<n);
ll ori=0;rep(i,1,n)ori+=max(s[i].b-s[i].a,0);
rep(i,1,k)ori-=v[i];
ans.a=1;ans.b=1;
rep(i,1,n){
ll tot=ori;
if(i<=k)tot=tot+s[i].a-v[k+1];else tot-=max(s[i].b-s[i].a,0);
upd(ans,(Frac){s[i].a-tot,s[i].b});
// printf("%d %lld %lld\n",i,s[i].a-tot,s[i].b);
}
ll x=ans.a,y=ans.b;
// printf("%d %lld %lld\n",k,x,y);
ans=(Frac){y-x+y*k,n*y};ans=Norm(ans);
printf("%lld %lld\n",ans.a,ans.b);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
priority_queue <pll> P, Q;
ll A[101010], B[101010], C[101010];
ll n, k, s, p, q;
ll gcd(ll a, ll b) { for(; b; swap(a, b)) a %= b; return a; }
void update(ll a, ll b) { if(p * b < a * q) p = a, q = b; }
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll i, x;
cin >> n;
for(i = 0; i < n; i ++){
cin >> A[i] >> B[i];
if(A[i] < B[i]){
s += B[i] - A[i];
P.emplace(-B[i], i);
C[i] = 1;
}
else Q.emplace(-A[i], i);
}
for(k = 0; ; k ++){
if(!P.empty() && (Q.empty() || P.top() > Q.top())){
tie(x, i) = P.top();
if(s + x < 0) break;
P.pop();
}
else if(!Q.empty()){
tie(x, i) = Q.top();
if(s + x < 0) break;
Q.pop();
}
else break;
s += x; C[i] = 2;
}
p = 0; q = 1;
for(i = 0; i < n; i ++){
if(C[i] == 0){
if(s + B[i] - A[i] >= 0){
update(s + B[i] - A[i], B[i]);
}
}
else if(C[i] == 1) update(s, B[i]);
else{
if(!P.empty() && (Q.empty() || P.top() > Q.top())){
x = P.top().first;
}
else if(!Q.empty()){
x = Q.top().first;
}
else x = -1e18;
if(s + B[i] + x >= 0){
update(s + B[i] + x, B[i]);
}
}
}
p += q * k; q *= n;
x = gcd(p, q);
p /= x; q /= x;
cout << p << " " << q << "\n";
return 0;
} |
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
// hloya template v26
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <bits/stdc++.h>
using namespace std;
bool dbg = 0;
clock_t start_time = clock();
#define current_time fixed<<setprecision(6)<<(ld)(clock()-start_time)/CLOCKS_PER_SEC
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))
#define ull unsigned long long
#define ll long long
#define ld long double
#define pii pair<int,int>
#define umap unordered_map<int, int>
#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("output.txt","w",stdout)
#define files files1;files2
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
// #define endl '\n'
#define ln(i,n) " \n"[(i) == (n) - 1]
void bad(string mes = "Impossible"){cout << mes;exit(0);}
void bad(int mes){cout << mes;exit(0);}
template<typename T>
string bin(T x, int st = 2){
string ans = "";
while (x > 0){
ans += char('0' + x % st);
x /= st;
}
reverse(ans.begin(), ans.end());
return ans.empty() ? "0" : ans;
}
mt19937_64 mt_rand(
chrono::system_clock::now().time_since_epoch().count()
);
template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }
// inline int popcount(int x){
// int count = 0;
// __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
// return count;
// }
template<typename T>
T input(){
T ans = 0, m = 1;
char c = ' ';
while (!((c >= '0' && c <= '9') || c == '-')) {
c = getchar();
}
if (c == '-')
m = -1, c = getchar();
while (c >= '0' && c <= '9'){
ans = ans * 10 + (c - '0'), c = getchar();
}
return ans * m;
}
template<typename T>
T gcd (T a, T b) { while (b) { a %= b; swap (a, b); } return a; }
template<typename T> void read(T& a) { a = input<T>(); }
template<typename T> void read(T& a, T& b) { read(a), read(b); }
template<typename T> void read(T& a, T& b, T& c) { read(a, b), read(c); }
template<typename T> void read(T& a, T& b, T& c, T& d) { read(a, b), read(c, d); }
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = (int)1e5 + 3, base = 998244353;
const ll llinf = 2e18 + 5;
int binpow(int a, int s) {
int res = 1;
while (s) {
if (s % 2) {
res = 1ll * res * a % base;
}
a = 1ll * a * a % base;
s /= 2;
}
return res;
}
struct Frac {
ll p, q;
Frac() {p = 0, q = 1;}
Frac(ll p, ll q) : p(p), q(q) {}
void norm() {
if (q < 0) p = -p, q = -q;
if (p == 0) q = 1;
ll g = gcd(abs(p), q);
p /= g;
q /= g;
}
Frac& operator+=(const Frac& b) {
p = p * b.q + q * b.p;
q = q * b.q;
norm();
return *this;
}
friend Frac operator+(Frac a, const Frac& b) {
a += b;
return a;
}
Frac& operator*=(const Frac& b) {
p = p * b.p;
q = q * b.q;
norm();
return *this;
}
friend Frac operator*(Frac a, const Frac& b) {
a *= b;
return a;
}
Frac& operator-=(const Frac& b) {
p = p * b.q - q * b.p;
q = q * b.q;
norm();
return *this;
}
friend Frac operator-(Frac a, const Frac& b) {
a -= b;
return a;
}
Frac& operator/=(const Frac& b) {
p = p * b.q;
q = q * b.p;
norm();
return *this;
}
friend Frac operator/(Frac a, const Frac& b) {
a /= b;
return a;
}
bool operator < (const Frac & T) const {
return p * T.q < T.p * q;
}
bool operator <= (const Frac & T) const {
return p * T.q <= T.p * q;
}
bool operator != (const Frac & T) const {
return p * T.q != T.p * q;
}
bool operator == (const Frac & T) const {
return p * T.q == T.p * q;
}
};
std::ostream& operator<<(std::ostream& out, const Frac& f) {
return out << f.p << ' ' << f.q;
}
pair<ll, int> tree[4 * maxn];
void upd(int v, int tl, int tr, int p, int val) {
if (tl == tr) {
tree[v] = mp(val, 1);
return;
}
int tm = (tl + tr) / 2;
if (p <= tm) {
upd(v<<1, tl, tm, p, val);
} else {
upd(v<<1|1, tm + 1, tr, p, val);
}
tree[v].f = tree[v<<1].f + tree[v<<1|1].f;
tree[v].s = tree[v<<1].s + tree[v<<1|1].s;
}
pair<ll, int> get(int v, int tl, int tr, ll h) {
// cout << v << ' ' << tl << ' ' << tr << ' ' << h << endl;
if (tl == tr) {
if (h >= tree[v].f) {
// cout << h << ' ' << tree[v].f << endl;
return {h - tree[v].f, tree[v].s};
} else {
return {h, 0};
}
}
int tm = (tl + tr) / 2;
if (h >= tree[v<<1].f) {
auto e = get(v<<1|1, tm + 1, tr, h - tree[v<<1].f);
return {e.f, e.s + tree[v<<1].s};
}
return get(v<<1, tl, tm, h);
}
Frac solve() {
int n;
// ifstream cin("input.txt");
cin >> n;
for (int i = 0; i < 4 * n; i++) {
tree[i] = mp(0, 0);
}
vector<pii> tmp;
vector<pair<pii, int>> ra;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
tmp.pb(mp(x, i));
ra.pb(mp(mp(y, x), i));
}
sort(all(tmp));
ll diff = 0;
sort(all(ra));
reverse(all(ra));
vector<ll> fdf(n, 0);
for (int i = 0; i < n; i++) {
fdf[i] = diff;
diff += max(0, ra[i].f.f - ra[i].f.s);
}
int max_full = 0;
Frac max_frac(0, 1);
for (int i = n - 1; i >= 0; i--) {
ll hv = fdf[i];
hv += ra[i].f.f - ra[i].f.s;
if (hv >= 0) {
pair<ll, int> cc = get(1, 0, n - 1, hv);
hv = cc.f;
Frac cur(min((ll)ra[i].f.f, hv), ra[i].f.f);
if (cur == Frac(1, 1)) {
cc.s += 1;
cur = Frac(0, 1);
}
if (cc.s > max_full) {
max_full = cc.s;
max_frac = cur;
} else if (cc.s == max_full) {
upmax(max_frac, cur);
}
}
auto ps = lower_bound(all(tmp), mp(ra[i].f.s, ra[i].s)) - tmp.begin();
upd(1, 0, n - 1, ps, ra[i].f.s);
}
Frac ans = Frac(max_full, 1) + max_frac;
ans.norm();
ans.q *= n;
ans.norm();
assert(ans.q > 0);
return ans;
}
Frac brute() {
ifstream cin("input.txt");
int n;
cin >> n;
vector<pii> rb;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
rb.pb(mp(x, y));
}
sort(all(rb));
Frac ans(0, 1);
do {
ll sa = 0;
for (int i = 0; i < n; i++) {
sa += rb[i].f;
vector<int> bb;
for (int j = i; j >= 0; j--) {
bb.pb(rb[j].s);
}
int ptr = 0;
ll tkn = sa;
while (ptr < bb.size() && tkn >= bb[ptr]) {
tkn -= bb[ptr];
ptr++;
}
if (ptr < bb.size()) {
Frac cur((ll)bb.size() - ptr - 1, 1);
cur += Frac(bb[ptr] - tkn, (ll)bb[ptr]);
upmax(ans, cur);
// if (!(cur != Frac(n, 3))) {
// for (int i = 0; i < n; i++) {
// cout << rb[i].f << ' ' << rb[i].s << endl;
// }
// // exit(0);
// cout << "===="<<endl;
// }
}
}
} while (next_permutation(all(rb)));
ans.q *= n;
ans.norm();
return ans;
}
void gen() {
ofstream cout("input.txt");
int n = rand() % 5 + 1;
cout << n << "\n";
for (int i = 0; i < n; i++) {
cout << rand() % 10 + 1 << ' ' << rand() % 10 + 1 << "\n";
}
}
int main() {
// files1;
fast_io;
// cout << solve() << endl;
// cout << brute() << endl;
// return 0;
cout << solve();
return 0;
// for (int iter = 0; iter < 100000; iter++) {
// gen();
// if (iter % 1000 == 0) {
// cout << iter << " ok" << endl;
// }
// if (auto a = solve(), b = brute(); a != b) {
// cout << a << ' ' << b << endl;
// exit(228);
// }
// }
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct PQ{
priority_queue<ll>d;
priority_queue<ll,vector<ll>,greater<ll>>u;
ll ds,dn;
PQ(void){
ds=0,dn=0;
}
void psd(ll x){
d.push(x);
ds+=x;
dn++;
}
ll ppd(void){
ll res=d.top();
ds-=res;
dn--;
d.pop();
return res;
}
void psu(ll x){
u.push(x);
}
ll ppu(void){
ll res=u.top();
u.pop();
return res;
}
};
ll gcd(ll x,ll y){
if(x<y)swap(x,y);
if(y==0)return 1;
if(x%y==0)return y;
return gcd(y,x%y);
}
ll n,s,ansx,ansy=1;
P x[100005];
PQ pq;
int main(void){
cin>>n;
for(int i=0;i<n;i++)cin>>x[i].S>>x[i].F;
sort(x,x+n);
for(int i=0;i<n;i++)s+=max(0LL,x[i].F-x[i].S);
for(int i=0;i<n;i++){
s-=max(0LL,x[i].F-x[i].S);
while(!pq.u.empty()&&pq.ds+x[i].S+pq.u.top()<=s+x[i].F)pq.psd(pq.ppu());
ll nx=0,ny=1;
if(pq.ds+x[i].S<=s+x[i].F&&s<=pq.ds+x[i].S)ny=x[i].F,nx=pq.dn*ny+x[i].F-x[i].S+s-pq.ds;
if(D(ansx)/D(ansy)<D(nx)/D(ny))ansx=nx,ansy=ny;
pq.psd(x[i].S);
pq.psu(pq.ppd());
}
ansy*=n;
ll g=gcd(ansx,ansy);
if(ansx==0)ansy=1;
ansx/=g,ansy/=g;
cout<<ansx<<' '<<ansy<<endl;
}
|
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
struct Node
{
int a,b;
}p[N];
long long sum[N];
struct Fraction
{
long long p,q;
bool operator<(const Fraction &b)const
{
return (double)p/q<(double)b.p/b.q;
}
};
long long gcd(long long a,long long b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&p[i].a,&p[i].b);
sort(p+1,p+n+1,[=](const Node &x,const Node &y){return max(x.a,x.b)<max(y.a,y.b);});
for(int i=n;i>=1;i--)
sum[i]=sum[i+1]+max(p[i].a,p[i].b);
long long to=0;
for(int i=1;i<=n;i++)
to+=p[i].a;
Fraction ans=(Fraction){0,1};
for(int i=1;i<=n;i++)
{
int pos=n+1;
int l=1,r=n;
auto check=[=](int x){return sum[x]-(x<=i?max(p[i].a,p[i].b):0)>=to-p[i].b;};
while(l<=r)
{
int mid=(l+r)/2;
if(check(mid)) l=mid+1,pos=mid;
else r=mid-1;
}
if(pos>n) continue;
long long ret=sum[pos]-(pos<=i?max(p[i].a,p[i].b):0)-(to-p[i].b);
Fraction res=(Fraction){1LL*(pos-1-(pos>i))*p[i].b+min(ret,(long long)p[i].b),1LL*p[i].b*n};
ans=max(ans,res);
}
long long d=gcd(ans.p,ans.q);
ans.p/=d,ans.q/=d;
printf("%lld %lld",ans.p,ans.q);
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
template<typename T>inline void read(T &x){
x=0;ll f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
x=x*f;
}
}
using namespace IO;
typedef pair<ll,ll> frac;
ll N,S=0;
vector<frac> T;
bool mp(frac A,frac B)
{
return (A.first*B.second<A.second*B.first);
}
ll gcd(ll x,ll y) { return (!y)?x:gcd(y,x%y); }
signed main()
{
read(N);
for(int i=1;i<=N;i++)
{
ll x,y;
read(x),read(y);
S+=x;
T.push_back(make_pair(std::max(x,y),y));
}
sort(T.begin(),T.end(),greater<frac>());
ll pos=0;
ll point=-1;
int ca=0;
for(auto it=T.begin();it!=T.end();it++)
{
if((pos+it->first) >S) break;
pos+=it->first;
point=it-T.begin();
ca++;
}
if(ca==N){cout<<"0 1"<<endl;return 0;}
frac ans(0,1);
for(int i=0;i<T.size();++i)
{
if(i>point)
{
if(pos+T[i].second>=S)
{
frac res(pos+T[i].second-S,T[i].second);
ans=(mp(ans,res))?res:ans;
}
}
else
{
if(pos-T[i].first+T[point+1].first+T[i].second>=S)
{
frac res(pos-T[i].first+T[point+1].first+T[i].second-S,T[i].second);
ans=(mp(ans,res))?res:ans;
}
}
}
ans.first+=ans.second*(N-ca-1);ans.second*=N;
ll _f=gcd(ans.first,ans.second);
cout<<ans.first/_f<<" "<<ans.second/_f<<endl;
return 0;
} |
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
using namespace std;
typedef pair<llint, llint> P;
llint n;
llint a[100005], b[100005];
P p[100005];
llint pos[100005], sum[100005], S;
llint gcd(llint a, llint b)
{
if(b == 0) return a;
return gcd(b, a%b);
}
P getmax(P p, P q)
{
if(p.first/p.second < q.first/q.second) return q;
if(p.first/p.second > q.first/q.second) return p;
llint P = p.first % p.second, Q = q.first % q.second;
if(P*q.second <= Q*p.second) return q;
else return p;
}
P reduce(P p)
{
if(p.first == 0) return P(0, 1);
llint g = gcd(p.first, p.second);
p.first /= g, p.second /= g;
return p;
}
P calc(llint i)
{
llint ub = n, lb = -1, mid;
while(ub-lb>1){
mid = (ub+lb)/2;
llint tmp = sum[mid];
if(i <= mid) tmp -= p[i].first;
if(tmp >= S-b[p[i].second]) ub = mid;
else lb = mid;
}
llint tmp = sum[ub];
if(i <= ub) tmp -= p[i].first, ub--;
if(tmp >= S) return P(0, 1);
llint x = n-ub, y = S-tmp;
P ret = reduce(P(max(0LL, b[p[i].second]*x-y), b[p[i].second]));
return ret;
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
p[i] = P(max(a[i], b[i]), i);
}
sort(p+1, p+n+1);
reverse(p+1, p+n+1);
for(int i = 1; i <= n; i++){
sum[i] = sum[i-1] + p[i].first;
S += a[i];
}
P ans = P(0, 1);
for(int i = 1; i <= n; i++) ans = getmax(ans, calc(i));
ans.second *= n;
ans = reduce(ans);
cout << ans.first << " " << ans.second << endl;
return 0;
} |
#include<bits/stdc++.h>
#define N 100100
using namespace std;
struct seg{
int a,b,x;
bool operator<(seg rhs)const{return x<rhs.x||x==rhs.x&&b<rhs.b;}
}p[N];
long long gcd(long long x,long long y){
while(y){
x%=y;
x^=y^=x^=y;
}
return x;
}
bool ca(seg x,seg y){
return x.a<y.a;
}
int main(){
int n,f=0,cur;
long long tx=0,ty=1;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&p[i].a,&p[i].b);
p[i].x=max(p[i].a,p[i].b);
}
long long pre=0;
for(int i=0;i<n;i++){
if(p[i].a<p[i].b){
pre+=p[i].a-p[i].b;
}
}
sort(p,p+n);
for(int i=0;i<n;i++){
if(pre+p[i].x<=0){
pre+=p[i].x;
f++;
}
else{
cur=i;
break;
}
}
for(int i=0;i<n;i++){
if(i<cur){
if(pre-p[i].x+p[cur].x+max(p[i].a-p[i].b,0)<=0){
long long cx=pre-p[i].x+p[cur].x+max(p[i].a-p[i].b,0);
long long cy=p[i].b;
if(-cx*ty>tx*cy){
tx=-cx;
ty=cy;
}
}
}
else{
if(pre+max(p[i].a-p[i].b,0)<=0){
long long cx=pre+max(p[i].a-p[i].b,0);
long long cy=p[i].b;
if(-cx*ty>tx*cy){
tx=-cx;
ty=cy;
}
}
}
}
long long x=1LL*f*ty+tx;
long long y=1LL*n*ty;
long long g=gcd(x,y);
printf("%lld %lld\n",x/g,y/g);
return 0;
} |
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
LL f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
if(x<0){putchar('-');x=-x;}
if(!x){putchar('0');return;}
int top=0;
while(x)stack[++top]=x%10,x/=10;
while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
struct line{int A,B,val;}w[MAXN];
bool cmp(line n1,line n2){return n1.val>n2.val;}
int n;LL pre[MAXN],S,mn1[MAXN],mn2[MAXN];
LL getval(int a,int b){return a<b?pre[a]:pre[a]-w[b].val;}
LL gcd(LL a,LL b){return a==0?b:gcd(b%a,a);}
int main()
{
// freopen("01-10.txt","r",stdin);
n=read();
for(int i=1;i<=n;i++)w[i].A=read(),w[i].B=read(),w[i].val=max(w[i].A,w[i].B),S+=w[i].A;
sort(w+1,w+1+n,cmp);
for(int i=1;i<=n;i++)pre[i]=pre[i-1]+w[i].val;
LL ansx=0,ansy=1;
for(int i=1;i<=n;i++)
{
int l=1,r=n,ps=-1;
while(l<=r)
{
int mid=(l+r)/2;
if(getval(mid,i)>=S)r=mid-1;
else if(getval(mid,i)+w[i].B<S)l=mid+1;
else {ps=mid;r=mid-1;}
}if(ps==-1)continue;
int id=i;LL S2=getval(ps,i)+w[i].B-S;
LL nowx=n-ps-(ps<i),nowy=1;
LL fx=S2,fy=w[id].B;LL d=gcd(fx,fy);fx/=d;fy/=d;
nowy=fy;nowx=fx+fy*nowx;d=gcd(nowx,nowy);nowx/=d;nowy/=d;
if(1.0*ansx*nowy<=1.0*ansy*nowx)ansx=nowx,ansy=nowy;
}
ansy=1LL*ansy*n;LL d=gcd(ansx,ansy);ansx/=d;ansy/=d;
pr1(ansx);pr2(ansy);
// if(1.0*2730399553711*372637208115>1.0*2981097664920*186319854506)puts("YES");
return 0;
}
//2730399553711 2981097664920
//186319854506 372637208115 |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
return os<<"{"<<p.a<<","<<p.b<<"}";
}
template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
os<<"{";
for(auto e:v)os<<e<<",";
return os<<"}";
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
int n;cin>>n;
int as=0;
vc<pi> ab;
rep(_,n){
int a,b;cin>>a>>b;
ab.eb(max(a,b),b);
as+=a;
}
sort(all(ab),greater<pi>());
int s=0,k=0;
while(1){
s+=ab[k++].a;
if(s>=as)break;
}
int num=1,den=1;
auto upd=[&](int x,int y){
if(num*y>x*den)
tie(num,den)=tie(x,y);
};
rep(i,n){
int w=as-(s-ab[min(i,k-1)].a);
if(w<=ab[i].b)
upd(w,ab[i].b);
}
num=den-num+den*(n-k);
den*=n;
int g=gcd(num,den);
cout<<num/g<<" "<<den/g<<endl;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.