Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)

编程入门 行业动态 更新时间:2024-10-14 22:19:29

Remainder Problem(分块)  <a href=https://www.elefans.com/category/jswz/34/1765055.html style=Educational Codeforces Round 71 (Rated for Div. 2)"/>

Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)

引用:

下面代码写错了,注意要上面这种。查:2  800  0,下面代码就错了。

  1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
  2 #include <cstdio>//sprintf islower isupper
  3 #include <cstdlib>//malloc  exit strcat itoa system("cls")
  4 #include <iostream>//pair
  5 #include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
  6 #include <bitset>
  7 //#include <map>
  8 //#include<unordered_map>
  9 #include <vector>
 10 #include <stack>
 11 #include <set>
 12 #include <string.h>//strstr substr
 13 #include <string>
 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
 15 #include <cmath>
 16 #include <deque>
 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
 18 #include <vector>//emplace_back
 19 //#include <math.h>
 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
 23 #define fo(a,b,c) for(register int a=b;a<=c;++a)
 24 #define fr(a,b,c) for(register int a=b;a>=c;--a)
 25 #define mem(a,b) memset(a,b,sizeof(a))
 26 #define pr printf
 27 #define sc scanf
 28 #define ls rt<<1
 29 #define rs rt<<1|1
 30 typedef long long ll;
 31 void swapp(int &a,int &b);
 32 double fabss(double a);
 33 int maxx(int a,int b);
 34 int minn(int a,int b);
 35 int Del_bit_1(int n);
 36 int lowbit(int n);
 37 int abss(int a);
 38 //const long long INF=(1LL<<60);
 39 const double E=2.718281828;
 40 const double PI=acos(-1.0);
 41 const int inf=(1<<30);
 42 const double ESP=1e-9;
 43 const int mod=(int)1e9+7;
 44 const int N=(int)1e6+10;
 45 
 46 ll a[N];
 47 ll ans[705][705];
 48 
 49 int main()
 50 {
 51     int n;
 52     sc("%d",&n);
 53     fo(n_,1,n)
 54     {
 55         int judge,x,y;
 56         sc("%d%d%d",&judge,&x,&y);
 57         if(judge==1)
 58         {
 59             a[x]+=y;
 60             for(int i=1;i<=700;++i)
 61                 ans[x%i][i]+=y;
 62         }
 63         else
 64         {
 65             ll Ans=0;
 66             if(x<=700)
 67                 Ans+=ans[y][x];
 68             else
 69                 for(int i=1;i<=500000;i+=x)
 70                     Ans+=a[i+y-1];
 71             pr("%lld\n",Ans);
 72         }
 73     }
 74     return 0;
 75 }
 76 
 77 /**************************************************************************************/
 78 
 79 int maxx(int a,int b)
 80 {
 81     return a>b?a:b;
 82 }
 83 
 84 void swapp(int &a,int &b)
 85 {
 86     a^=b^=a^=b;
 87 }
 88 
 89 int lowbit(int n)
 90 {
 91     return n&(-n);
 92 }
 93 
 94 int Del_bit_1(int n)
 95 {
 96     return n&(n-1);
 97 }
 98 
 99 int abss(int a)
100 {
101     return a>0?a:-a;
102 }
103 
104 double fabss(double a)
105 {
106     return a>0?a:-a;
107 }
108 
109 int minn(int a,int b)
110 {
111     return a<b?a:b;
112 }

 

转载于:.html

更多推荐

Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)

本文发布于:2024-03-09 21:30:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1726151.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Educational   Problem   Remainder   Codeforces   Div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!