Parity check 大數取模

2021-08-06 07:26:00 字數 907 閱讀 7815

parity check

time limit: 2000ms memory limit: 524288kb

submit statistic

problem description

fascinated with the computer games, gabriel even forgets to study. now she needs to finish her homework, and there is an easy problem:

f(n)=

she is required to calculate f(n) mod 2 for each given n. can you help her?

input

multiple test cases. each test case is an integer n(0≤n≤) in a single line.

output

for each test case, output the answer of f(n)mod2.

example input

2 example output

1 hint

author

「浪潮杯」山東省第八屆acm大學生程式設計競賽(感謝青島科技大學)

找規律, 會發現%2, 每三位 就是0 1 1 因此 看是 %3 餘幾即可 但又因為是10^1000 因此是個大數 ,大數取模處理 就行

#include 

using

namespace

std;

int main()

if(sum==1||sum==2)

cout

<<1

cout

<<0

0;}

大數取模運算

問題分析 1 大數儲存 由於x的位數最大為400位,我們不能用現有的int,long,long long,double等資料型別進行儲存。一般儲存大數的方法是用乙個字串來表示。2 取模運算 模擬手算豎式的方法。用x從高到低的每一位加上前一位餘數 10來對bi進行 最後得到的結果就是x bi的結果。利...

大數階乘取模

水了90分。如果不會正解的話,直接暴力拿分,無腦暴力可以拿到90分 正解分塊打表 就是直接求階乘然後取模。加乙個比較有用的特判 如果n p,那麼n的階乘的因子中一定有p,n的階乘膜p一定等於0 include include using namespace std long long n,p int...

大數階乘取模

暴力 就是直接求階乘然後取模。加乙個比較有用的特判 如果n p,那麼n的階乘的因子中一定有p,n的階乘膜p一定等於0 include include using namespace std long long n,p intjs int n return ans int main else retu...