# CF #308 (Div. 2)

151人阅读 评论(0)

A. Vanya and Table

#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
//#define ONLINE_JUDGE
#define eps 1e-10
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,c)scanf("%d%d%d",&a,&b,&c)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll __int64
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
int n,m;
int s;
#define N 2010
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
while(scanf("%d",&n)!=EOF){
int ans=0;
int x1,y1,x2,y2;
while(n--){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for(int i=x1;i<=x2;i++)
for(int j=y1;j<=y2;j++)
ans++;
}
printf("%d\n",ans);
}
return 0;
}

B. Vanya and Books

#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
//#define ONLINE_JUDGE
#define eps 1e-10
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,c)scanf("%d%d%d",&a,&b,&c)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll __int64
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
int n,m;
int s;
#define N 2010
ll f[20];
void Init(){
int bas = 9;
int mul = 1;
for(int i=1;i<10;i++){
f[i] = bas*mul;
mul *= 10;
}
}
ll getNum(int num){
ll s=1;
while(num--){
s *= 10;
}
return s;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
Init();
while(scanf("%d",&n)!=EOF){
int sum=0;
int tmp = n;
while(tmp){
sum++;
tmp /= 10;
}
//      printf("%d\n",sum);
ll ans = 0;
for(int i=1;i<sum;i++)
ans += (f[i]*i);
ans += (n-(getNum(sum-1))+1)*sum;
printf("%I64d\n",ans);
}
return 0;
}

C. Vanya and Scales

#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
//#define ONLINE_JUDGE
#define eps 1e-10
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,c)scanf("%d%d%d",&a,&b,&c)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll __int64
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
int n,m;
int s;
#define N 2010
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
int w;
while(scanf("%d%d",&w,&m)!=EOF){
int flag = 1;
while(m){
int tmp = m%w;
m /= w;
if(tmp == 0)
continue;
else if(tmp == 1)
continue;
else if(tmp == w-1)
m++;
else{
flag = 0;
break;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

D. Vanya and Triangles

#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
//#define ONLINE_JUDGE
#define eps 1e-10
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,c)scanf("%d%d%d",&a,&b,&c)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll __int64
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
int n,m;
int s;
#define N 2010
struct Point{
int x,y;
friend int operator *(Point A,Point B){return (A.x*B.y)-(A.y*B.x);}
friend Point operator -(Point A,Point B){Point C;C.x=A.x-B.x;C.y=A.y-B.y;return C;}
}a[N];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
int w;
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++)
scanf("%d%d",&a[i].x,&a[i].y);
int ans=0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
for(int k=j+1;k<n;k++)
if((a[i]-a[j])*(a[j]-a[k])) ans++;  //不共线
printf("%d\n",ans);
}
return 0;
}

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：15958次
• 积分：1085
• 等级：
• 排名：千里之外
• 原创：93篇
• 转载：0篇
• 译文：0篇
• 评论：9条
最新评论
• hdu 5536

leohujx: @yskyskyer123:是的~我之前忽略了那个固定30次的循环，这样说来应该是这样的，多谢指点~

• hdu 5536

yskyskyer123: @leohujx:本人才疏学浅，后来我问了学长，自己也想了想，因为树的深度是32（算上根结点），而n...

• hdu 5536

leohujx: @yskyskyer123:你好，其实我并不清楚上限是多少，但是肯定没有您说的那么大，因为虽然数字可...

• hdu 5536

yskyskyer123: 请问那个结点上限#define M 100010是怎么算出来的pow(2,31)不是= 2 147 ...

• hdu5355

leohujx: @maxichu:不好意思哈，前几天没上博客，今天刚看到你的回复。我的理解是这样的：1.反过来看，不...

• hdu5355

maxichu: 不过还有两个问题希望兄台能够解答下呢、、一是为啥满足那两个条件就一定存在啊？感觉难以证明。。。二是为...

• hdu5355

maxichu: 好详细的解答，，一直再纠结为什么要4m-1。。。太感谢你啦~

• hdu5335

leohujx: @David_Jett:哈哈，谢谢你的夸奖，如果哪里有错还请指教~

• hdu5335

David_Jett: 良心博客啊，写博客就应该像博主这样！