码迷,mamicode.com
首页 > 其他好文 > 详细

SRM 11爆0记

时间:2017-08-08 23:12:15      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:solution   code   get   stdin   分类   img   pre   ora   noip   

难度区间:NOIP提高-

第一题

题意:

滚来滚去

技术分享

 

技术分享

 

Solution

刚开始写了O(n)的60分模拟,打了1h的状态表,结果写砸了只剩35分QAQ

对于30%的数据:O(n^2)模拟

对于60%的数据:O(1)求横向翻转,O(n)模拟向下翻转的情况

对于100%的数据:时间复杂度:O(1)

分类讨论:

用真.骰子模拟可得:

当c%4=0时,ans=r*c/2*7;

当c%4=1时,循环节为(第1-4行):技术分享即:1,5,6,2,易得ans=c/4*14*r+循环节sum=(c>>1)*7*r+循环节sum

当c%4=2时,循环节为(第1-6行):      技术分享,同理易得ans

当c%4=3时,循环节为(第1-2行):技术分享,同理易得ans

Code:

技术分享
 1 #include <iostream>
 2 #include <cstdio>
 3 #define ll long long 
 4 using namespace std;
 5 ll r,c,yu2[10],yu1[10];// 1:r 0:l
 6 void read(ll &k)
 7 {
 8     ll f=1;k=0;char c=getchar();
 9     while (c<0||c>9)c==-&&(f=-1),c=getchar();
10     while (c>=0&&c<=9)k=k*10+c-0,c=getchar();
11     k*=f;
12 }
13 int main()
14 {
15     freopen("dice.in","r",stdin);
16     freopen("dice.out","w",stdout);
17     read(r);read(c);
18     yu2[1]=5;yu2[2]=11;yu2[3]=19;yu2[4]=28;yu2[5]=36;yu2[0]=0;
19     yu1[1]=1;yu1[2]=6;yu1[3]=12;yu1[0]=0;
20     ll chu=c/4,yu=c%4;
21     if (yu==3)printf("%lld\n",chu*14*r+11*r);
22     if (yu==2)printf("%lld\n",chu*14*r+42*((ll)r/6)+yu2[r%6]);
23     if (yu==1)printf("%lld\n",chu*14*r+14*((ll)r/4)+yu1[r%4]);
24     if (!(c%4))printf("%lld\n",r*(c>>1)*7);
25 }
View Code

 

 

 

 

 

SRM 11爆0记

标签:solution   code   get   stdin   分类   img   pre   ora   noip   

原文地址:http://www.cnblogs.com/mczhuang/p/7309159.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!