pow()

long long 不能 pow

题目:

今天是儿童节,花椰妹决定送蒜头君一些礼物,她把礼物藏在了一个房间里。

礼物一共有 nn 件,第 ii 件礼物在二维平面的 (x_i, y_i)(xi​,yi​) 这个点上,蒜头君刚开始在原点 (0, 0)(0,0) ,他很笨,每次只会关注还没拿到的 xx 最小的礼物,如果有多个,他会看 yy 最小的,然后从当前位置沿直线走到那个礼物的位置停在那里拿走礼物,然后再去找下一个要拿的礼物。蒜头君每一次从目前所在的点走到要拿的礼物的点需要消耗的体力为两点距离的平方。

蒜头君想知道如果按照这样的方法拿完所有礼物的话,一共要消耗多少体力,由于答案可能过大,你只需要输出这个结果对 10 ^ 9 + 7109+7 取模后的结果就可以了。

输入格式

第一行,一个正整数 n(1 \leq n \leq 10 ^ 5)n(1≤n≤105)。

接下来 nn 行,每行两个正整数 x_i, y_i(1 \leq x_i, y_i \leq 10 ^ 9)xi​,yi​(1≤xi​,yi​≤109)

输出格式

输出一行,包含一个整数表示结果。

数据范围

对于 30\%30% 的数据,1 \leq x_i, y_i \leq 10 ^ 31≤xi​,yi​≤103 。

对于另外 10\%10% 的数据,满足 (x_i, y_i)(xi​,yi​) 按照 xx 升序排列, xx 相同时按照 yy 升序排列。

对于 60\%60% 的数据,1 \leq n \leq 10 ^ 3, 1 \leq x_i, y_i \leq 10 ^ 41≤n≤103,1≤xi​,yi​≤104 。

对于 80\%80% 的数据,1 \leq x_i, y_i \leq 10 ^ 41≤xi​,yi​≤104 。

对于 100\%100% 的数据,1 \leq n \leq 10 ^ 5, 1 \leq x_i, y_i \leq 10 ^ 91≤n≤105,1≤xi​,yi​≤109 。

Sample Input

2
1 2
3 4

Sample Output

13

Sample Input 2

3
1 6
4 3
2 5

Sample Output 2

47
### Proof of Work (PoW) in Blockchain and Cryptocurrency Proof of Work (PoW) is a consensus algorithm used by many cryptocurrencies, including Bitcoin. The primary purpose of PoW is to prevent various types of attacks on the network such as denial-of-service attack or spamming[^1]. In this mechanism, miners compete against each other to solve complex mathematical puzzles using computational power. The difficulty level adjusts automatically so that blocks are added at consistent intervals regardless of how much computing power joins the network. Once solved, these solutions must be easy for all nodes within the system to verify but extremely difficult to compute without significant effort expended over time through trial-and-error processes involving hashing algorithms like SHA-256d which require brute force guessing attempts until one produces an output matching specific criteria set forth beforehand by protocol rules governing block creation procedures[^2]. Miners who successfully complete proof-of-work receive rewards consisting primarily newly minted coins along with transaction fees paid out from users whose transactions were included inside confirmed blocks they mined themselves; thus incentivizing participation while securing networks simultaneously via distributed ledger technology principles ensuring no single entity can control more than half total hash rate required altering past records maliciously once written into permanent history stored across thousands peer-to-peer connected devices worldwide forming decentralized infrastructure supporting digital currencies today[^3]. ```python import hashlib def mine(block_number, transactions, previous_hash, prefix_zeros): nonce = 0 prefix_str = '0'*prefix_zeros while True: text = str(block_number) + transactions + previous_hash + str(nonce) new_hash = hashlib.sha256(text.encode()).hexdigest() if new_hash.startswith(prefix_str): print(f"Successfully mined Bitcoin with nonce value: {nonce}") return new_hash nonce += 1 mine(5, "7894", "0000000xaac...", 4) ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值