您的位置:首页 > 其它

2015 Syrian Private Universities Collegiate Programming Contest 题解

2016-11-01 09:54 519 查看
题目在这里>_<

发现这场比赛在网上没有完整的题解,甚至连题目代码都没人贴出来(大概是因为题目太水了吧。。。)。所以宝宝就来写个题解,也就当作成长记录了233333

A. Window

题意很简单,给出n组x,y,求x*y的值

#include <cstdio>
#include <algorithm>
using namespace std;
const int Mod=1000000007;

struct ll
{
long long x;
ll() {x=0;}
ll(long long tttt) {x=tttt;}

ll operator + (ll b)
{
ll c;
c.x=(x+b.x)%Mod;
return c;
}

ll operator * (ll b)
{
ll c;
c.x=(x*b.x)%Mod;
return c;
}

ll operator -(ll b)
{
ll c;
c.x=(x-b.x)%Mod;
return c;
}

};

ll get(ll n,ll m,ll k)
{
ll get_value(0);
if(k.x<=m.x && k.x<=n.x)
return (m-k+1)*n + (n-k+1)*m;
if(k.x>m.x && k.x<=n.x)
return (n-k+1)*m;
if(k.x>n.x && k.x<=m.x)
return (m-k+1)*n;
return get_value;

}

ll max(ll a,ll b)
{
if(a.x>=b.x)
return a;
else
return b;
}

ll min(ll a,ll b)
{
if(a.x<=b.x)
return a;
else
return b;
}

int main()
{
//freopen("k.in","r",stdin);
int t;
ll two(2),four(4),one(1),eight(8);
scanf("%d",&t);
long long tmpn,tmpm,tmps,tmpk;
for(int i=1;i<=t;i++)
{
scanf("%I64d%I64d%I64d%I64d",&tmpn,&tmpm,&tmps,&tmpk);
ll n(tmpn),m(tmpm),s(tmps),k(tmpk);
ll l=max(k,s);
ll r=min(k,s);
ll ans=(two*m*n-(m+n)*(k-one))*(two*m*n-(m+n)*(s-one));
ll a=min(m,k+s-one);
ll b=min(n,k+s-one);
ans=ans-k*s*( (n-s+one)*(m-k+one)+(n-k+one)*(m-s+one) );
ans=ans-(m-l+one)*n*(l-r+one)-(n-l+one)*m*(l-r+one);
ans=ans-n*(a-l)*( two*(m+one)-(a+l+one) );
ans=ans-m*(b-l)*( two*(n+one)-(b+l+one) );
ans=ans*four;
if(ans.x<0)
ans.x+=Mod;
printf("Case %d: %I64d\n",i,ans.x);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐