google codejam 2008 round1B
来源:互联网 发布:php的mvp 编辑:程序博客网 时间:2024/05/17 03:54
Problem A. Crop Triangles、
大数据运行时间大约为430s
#pragma comment(linker, "/STACK:1024000000,1024000000")#include <iostream>#include <stdio.h>#include <fstream>#include <iomanip>#include <cmath>#include <string>#include <string.h>#include <sstream>#include <cctype>#include <climits>#include <set>#include <map>#include <deque>#include <queue>#include <vector>#include <iterator>#include <algorithm>#include <stack>#define _clr(x,y) memset(x,y,sizeof(x))#define _inf(x) memset(x,0x3f,sizeof(x))#define pb push_back#define mp make_pairusing namespace std;const int INF = 0x3f3f3f3f;const double eps = 1e-8;typedef long long LL;int main(){//ios_base::sync_with_stdio(false);cin.tie(0);#ifndef ONLINE_JUDGE//freopen("A-large-practice.in","r",stdin);//freopen("myout.txt","w",stdout);#endifint T;cin>>T;for(int cas=1;cas<=T;cas++){LL ans=0,cnt1[3][3]={0},cnt[3][3]={0};LL n,a,b,c,d,x0,y0,m;LL x[100000+5],y[100000+5];cin>>n>>a>>b>>c>>d>>x0>>y0>>m;x[0]=x0;y[0]=y0;cnt1[x0%3][y0%3]++;for(int i=1;i<n;i++){x[i]=(a*x[i-1]+b)%m;y[i]=(c*y[i-1]+d)%m;cnt1[x[i]%3][y[i]%3]++;}/*memcpy(cnt,cnt1,sizeof(cnt));for(int i=0;i<3;i++){for(int j=0;j<3;j++)cout<<cnt[i][j]<<" ";cout<<endl;}*/for(int i=0;i<n;i++){cnt1[x[i]%3][y[i]%3]--;memcpy(cnt,cnt1,sizeof(cnt));for(int j=i+1;j<n;j++){cnt[x[j]%3][y[j]%3]--;int dx=(x[i]+x[j])%3,dy=(y[i]+y[j])%3;ans+=cnt[(3-dx)%3][(3-dy)%3];}}/*for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++)if((x[i]+x[j]+x[k])%3==0&&(y[i]+y[j]+y[k])%3==0) ans++;*/cout<<"Case #"<<cas<<": "<<ans<<endl;} return 0;}
0 0
- google codejam 2008 round1B
- 2017Google Codejam round1b Problem B. Stable Neigh-bors
- 2017Google Codejam round1b Problem C. Pony Express
- google codejam 2008 round2
- google codejam 汇总
- Google code jam Round1B Problem B
- Google Code Jam Round1B B题
- Google CodeJam Qualification Round 2013
- Google CodeJam Round 2 2013
- Google CodeJam习题:Alien Numbers
- Google CodeJam Qualification Round 2014
- Google Codejam 2009 Round 2
- Google Code Jam2008 Round1B Number Sets(并查集)
- codejam 2008 practice problems
- codejam 2008 practice Contest
- codejam 2008 Qualification Round
- codejam-Round1A-2008-Numbers
- google codejam 2008 APAC local onsites , Problem A What are Birds?
- LeetCode 35. Search Insert Position
- P1403 [AHOI2005]约数研究
- Tomcat 容器与servlet的交互原理
- AForge.NET 入门
- skb 在网卡接收过程中的应用例子
- google codejam 2008 round1B
- 养成写博客的好习惯
- MIDI基本数据格式选项纯文本
- bzoj3123
- jQuery--筛选案例--QQ用户分组
- 强人工智能资料
- 《MySQL必知必会》学习笔记二------掌握部分
- 蓝桥杯方格填数
- H264编码器