ural 2062 Ambitious Experiment
2062. Ambitious Experiment
Memory limit: 128 MB
- Measure current charge of the particle number i.
- Direct radiation with power d at particles with numbers from l to r inclusive.
Input
- 1 i — measure current charge of the particle number i (1 ≤ i ≤ n).
- 2 l r d — direct radiation with power d at particles with numbers from l to r inclusive (1 ≤l ≤ r ≤ n, 0 ≤ d ≤ 106).
Output
Samples
input | output |
---|---|
3 |
12 |
6 |
3 |
Problem Source: Ural Regional School Programming Contest 2015
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mk make_pair inline int getInt()
{
int ret = ;
char ch = ' ';
bool flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
ret = ret * + ch - '';
ch = getchar();
}
return flag ? -ret : ret;
} const int N = , M = ;
int n, m;
LL block[N / M + ][M], tag[N / M + ], arr[N]; inline int getBlockIndex(int x)
{
return x / M;
} inline int getIndex(int x)
{
return x % M;
} inline void input()
{
cin >> n;
for(int i = ; i < n; i++) cin >> arr[i];
} inline LL work(int x)
{
int b = getBlockIndex(x), idx = getIndex(x);
return block[b][idx] + tag[b];
} inline LL query(int x)
{
x++;
LL ret = ;
for(int i = ; i * i <= x; i++)
if(x % i == )
{
ret += work(i - );
if(x / i != i) ret += work(x / i - );
}
return ret;
} inline void change(int l, int r, int d)
{
int left = getBlockIndex(l), right = getBlockIndex(r);
for(int i = left + ; i <= right - ; i++) tag[i] += d;
if(left < right)
{
for(int i = getIndex(l); i < M; i++) block[left][i] += d;
for(int i = ; i <= getIndex(r); i++) block[right][i] += d;
}
else
{
for(int i = getIndex(l); i <= getIndex(r); i++)
block[left][i] += d;
}
} inline void solve()
{
for(cin >> m; m--; )
{
int opt, l, r, x;
cin >> opt;
if(opt == )
{
cin >> x;
x--;
cout << query(x) + arr[x] << "\n";
}
else
{
cin >> l >> r >> x;
l--, r--;
change(l, r, x);
}
}
} int main()
{
ios::sync_with_stdio();
input();
solve();
return ;
}
ural 2062 Ambitious Experiment的更多相关文章
- URAL 2062 Ambitious Experiment(分块)
[题目链接] http://acm.timus.ru/problem.aspx?space=1&num=2062 [题目大意] 给出两个操作,操作一给出区间[l,r],对l到r中的每一个下标i ...
- ural2062 Ambitious Experiment
Ambitious Experiment Time limit: 3.0 secondMemory limit: 128 MB During several decades, scientists f ...
- Ural 2062:Ambitious Experiment(树状数组 || 分块)
http://acm.timus.ru/problem.aspx?space=1&num=2062 题意:有n个数,有一个值,q个询问,有单点询问操作,也有对于区间[l,r]的每个数i,使得n ...
- ural Ambitious Experiment 树状数组
During several decades, scientists from planet Nibiru are working to create an engine that would all ...
- 【树状数组】【枚举约数】 - Ambitious Experiment
给定一个序列,支持以下操作: 对区间[l,r]的每个i,将1i,2i,3i,...这些位置的数都加d. 询问某个位置的数的值. 如果把修改看作对区间[l,r]的每个数+d,那么询问x位置上的数时,显然 ...
- URAL 2062 树状数组
一个长度为n的数组 每次对lr区间进行修改 如果要修改i 则对i i*2 i*3...都修改 最后单点查询值 思想是利用树状数组维护每一个区间的更新值 查询的时候得出这个点的所有因子的查询值的和 加上 ...
- An interesting experiment on China’s censorship
This paper presented a very interesting topic. Censorship in China has always drawn people's attenti ...
- Reading With Purpose: A grand experiment
Reading With Purpose: A grand experiment This is the preface to a set of notes I'm writing for a sem ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
随机推荐
- LoadRunner函数
一.基础函数简介 在VU左边导航栏中,有三个LoadRunner框架函数,分别是vuser_init().Action().vuser_end().这三个函数存在于任何Vuser类型的脚本中. vus ...
- AJAX 汽车详细信息练习
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- C#学习笔记-----C#枚举中的位运算权限分配
一.基础知识 什么是位运算? 用二进制来计算,1&2:这就是位运算,其实它是将0001与0010做位预算 得到的结果是 0011,也就是3 2.位预算有多少种?(我们就将几种我们权限中会 ...
- 对Cookie和Session的深入理解
session对象 session对象用于存储特定的用户会话所需的信息 . Session对象的引入是为了弥补HTTP协议的不足.HTTP协议本身是无状态的,这与HTTP协议本来的目的是相符的,客户端 ...
- djcelery的细节篇
http://blog.csdn.net/samed/article/details/50598371 随时撸一撸,要点记心间.. 1. 下面讲解一下celery.py文件的配置内容,为何要这么配置. ...
- 【20140113】package 与 import
一个完整的java源程序应该包括下列部分: package语句: //该部分至多只有一句,必须放在源程序的第一句 import语句: public classDefinition: //公共类定义部分 ...
- HDU4495 Rectangle
求组成的等腰三角形面积最大值. 对此题的总结:暴力出奇迹 组成的三角形放置方式一共只有4种,用ans表示目前已知的最长三角形的边长,从上到下,从左到右枚举顶点,再枚举边长,一个重要剪枝是枚举边长l时先 ...
- Win10 创建应用程序包及部署
https://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/hh454036.aspx https://msdn.microsoft.com/ ...
- WPF Navigation
在开始学习WPF时,一开始对WPF的Window, Page, UserControl感到很迷惑.不知道什么时候该使用哪一个.下面简单介绍一下这三者的区别. Window:故名思意,桌面程序的窗体.在 ...
- 深入理解ASP.NET 5的依赖注入
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:ASP.NET 5整个底层都架构于依赖注入机制之下,今天介绍的文章详细介绍了内置依赖注 ...