A. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
Square root digital expansion It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all. The square root of two i…
E. Square Root of Permutation A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = …
C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
It is possible to show that the square root of two can be expressed as an infinite continued fraction. 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.51 + 1/(2 + 1/2) = 7…
Square RootWhen the square root functional configuration is selected, a simplified CORDIC algorithm isused to calculate the positive square root of the input. The input, X_IN, and the output,X_OUT, are always positive and are both expressed as either…
A. Plus and Square Root 题目连接: http://codeforces.com/contest/715/problem/A Description ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is d…
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at t…
Tiny Wong the chef used to be a mathematics teacher in a senior high school. At that time, he always used to tell his students that when there is a square root of some number in one’s final result, it should be simplified by factoring out the largest…
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. F…
传送门 MD写一道二次剩余的板题差点写自闭了. 我用的是cipollacipollacipolla算法. 利用的是欧拉准则来找寻一个二次非剩余类来求根. 注意这题有两个等根和模数为2的情况. 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; int T,n,mod; inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,a=(ll)a*a%mo…
Description A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i…
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. F…
题意: 求\(x^2 \equiv a \mod p\) 的所有整数解 思路: 二次剩余定理求解. 参考: 二次剩余Cipolla's algorithm学习笔记 板子: //二次剩余,p是奇质数 ll ppow(ll a, ll b, ll mod){ ll ret = 1; a = a % mod; while(b){ if(b & 1) ret = ret * a % mod; a = a * a % mod; b >>= 1; } return ret; } struct TT…
from decimal import getcontext, Decimal def main(): n = int(raw_input()) p = int(raw_input()) getcontext().prec = p+10 # 扩大精度,保证接过 sum = 0 for i in range(1,n+1): nTemp = Decimal(i).sqrt() if nTemp._isinteger() : # 自生函数的判断 sum += 0 else: nTemp = str(n…
public class Solution { public static void main(String[] args) { Scanner ip = new Scanner(System.in); System.out.print("Enter a number: "); double n = ip.nextDouble(); System.out.println(sqrt(n)); ip.close(); } public static double sqrt(double n…
Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB. Output For each number Ai from the last one till the fi…
The problem is so easy, that the authors were lazy to write a statement for it! Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 10^18). The numbers are separated by any number of spaces and line breaks. A size of the input strea…
The problem is so easy, that the authors were lazy to write a statement for it! Input The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream…