//sgu 135
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
#define LL long long
LL n;
int main()
{
scanf("%lld",&n);
{
LL s;
s=(n+1)*n/2+1;
printf("%lld\n",s);
}
return 0;
}
//maxnum[i]=1+1+2+3+...+i;
//sgu 184
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
using namespace std;
#define LL long long
int p,m,c,k,r,v;
int min(int x,int y,int z)
{
if(x<y&&x<z)
return x;
if(y<x&&y<z)
return y;
return z;
}
int main()
{
cin>>p>>m>>c>>k>>r>>v;
cout<<min(p/k,m/r,c/v)<<endl;
return 0;
}
//sgu 117
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
using namespace std;
#define LL long long
int n,m,k;
int find(int a,int b,int mod)//快速谧,求pow(a,b)
{
int i,s=1;
while(b)
{
if(b&1)
s=(s*a)%mod;
a=(a*a)%mod;
b=b>>1;
}
return s;
}
int main()
{
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
int i,j,s=0,a;
for(i=0;i<n;i++)
{
scanf("%d",&a);
if(find(a,m,k)==0)
s++;
//printf("**%d\n",find(a,m,k));
}
printf("%d\n",s);
}
return 0;
}
SGU 126:
//sgu 126 每次从较多的一箱里取出跟较小一样多的球放到较小里,问最少要多少次,才能全放一个箱子里
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define LL __int64
#define min(a,b) ((a<b)?a:b)
LL num=0;
void find(LL m,LL n)
{
if(m==0||n==0)
return;
n=n-m;
m=m*2;
num++;
if(m<n)
find(m,n);
else
find(n,m);
}
int main(){
LL n,m;
while(scanf("%I64d %I64d",&n,&m)!=EOF)
{
LL i,j,k,s,t=0;
s=m+n;
if(n==0||m==0)
{
printf("0\n");
continue;
}
while(s!=1)
{
if(s%2==1)
t=1;
s=s/2;
}
num=0;
if(t==1)
printf("-1\n");
else
{
if(m<n)
find(m,n);
else
find(n,m);
printf("%I64d\n",num);
}
}
return 0;
}
SGU:114
//sgu 114
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL __int64
#define min(a,b) ((a<b)?a:b)
struct node{
int a,b;
}e[15001];
int cmp(node x,node y)
{
return x.a<y.a;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i,j,k,s=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&e[i].a,&e[i].b);
s+=e[i].b;
}
s=s/2;
int t=0;
sort(e,e+n,cmp);
for(i=0;i<n;i++)
{
t+=e[i].b;
if(s<=t)
{
printf("%.5f",1.0*e[i].a);
break;
}
}
}
return 0;
}
/*
题意:
找到一个点使得它到各点的距离与各点权重的积之和最小
方法
例:
4
1 3
2 1
5 2
6 2
sum=|x-1|+|x-1|+|x-1|+|x-2|+|x-5|+|x-5|+|x-6|+|x-6|最小
就是求1,1,1,2,5,5,6,6的中位数
*/
SGU 118:
//sgu 118 求 A1*A2*…*AN + A1*A2*…*AN-1 + … + A1*A2 + A1的f(n),
/*
int f(n)
{
if(s<=9)
reutrn s;
s=n的各个数位之和
return f(s);
}
找到规律发现f(n)==n%9==0?9:n%9
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL __int64
#define mod 9
int c[1001];
int find(int n)
{
int s=c[n];
for(int i=n-1;i>=1;i--)
s=(c[i]*(s+1))%mod;
return s;
}
int main()
{
int t,n,s;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&c[i]);
s=find(n);
printf("%d\n",s==0?9:s);
}
return 0;
}
SGU 127:
//sgu 127 从第三页开始添加号码,每页要首数字相同,个数不超过k个,问至少要多少页
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL __int64
int c[10001];
int main()
{
int k,n;
while(scanf("%d%d",&k,&n)!=EOF)
{
int i,j,u,t=1,s=1;
for(i=0;i<n;i++)
scanf("%d",&c[i]);
sort(c,c+n);
u=c[0]/1000;
for(i=1;i<n;i++)
{
if(u==c[i]/1000)
{
t++;
if(t>k){
s++;
t=1;
}
}
else{
u=c[i]/1000;
t=1;
s++;
}
}
printf("%d\n",s+2);
}
return 0;
}