标签:++ scan ring pac cst pre space sre string
思路:
维护两个指针pointer_1和pointer_2
代表用算法一走到的位置 和算法2走到的位置
若 算法一<算法2 数组后面就插入算法一的解 pointer_1++
(记得判重)
(这题卡不住heap什么鬼)
//By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef unsigned long long ul; ul a[4000050],c,n,a1,b1,c1,a2,b2,c2; int main(){ scanf("%llu%llu%llu%llu%llu%llu%llu%llu",&c,&n,&a1,&b1,&c1,&a2,&b2,&c2); a[1]=c; ul t1=a1*c/c1+b1,t2=a2*c/c2+b2; int pointer_1=1,pointer_2=1; for(int i=2;i<=n;){ if(t1<t2){ if(t1!=a[i-1])a[i++]=t1; t1=a[++pointer_1]*a1/c1+b1; } else{ if(t2!=a[i-1])a[i++]=t2; t2=a[++pointer_2]*a2/c2+b2; } }printf("%llu\n",a[n]); }
标签:++ scan ring pac cst pre space sre string
原文地址:http://www.cnblogs.com/SiriusRen/p/6654375.html