2026/2/21 17:04:25
网站建设
项目流程
室内设计网站,网页翻译不见了,wordpress的权限写入方法,做网站优化要多少钱P3917 异或序列
题目描述
给出序列 A1,A2,⋯,ANA_1,A_2,\cdots,A_NA1,A2,⋯,AN#xff0c;求 ∑1≤i≤j≤NAi⊕Ai1⊕⋯⊕Aj\sum_{1\le i\le j\le N} A_i\oplus A_{i1}\oplus\cdots\oplus A_j1≤i≤j≤N∑Ai⊕Ai1⊕⋯⊕Aj
的值。其中#xff0c;⨁\bigoplus⨁…P3917 异或序列题目描述给出序列A 1 , A 2 , ⋯ , A N A_1,A_2,\cdots,A_NA1,A2,⋯,AN求∑ 1 ≤ i ≤ j ≤ N A i ⊕ A i 1 ⊕ ⋯ ⊕ A j \sum_{1\le i\le j\le N} A_i\oplus A_{i1}\oplus\cdots\oplus A_j1≤i≤j≤N∑Ai⊕Ai1⊕⋯⊕Aj的值。其中⨁ \bigoplus⨁表示按位异或。输入格式第一行一个整数N NN。第二行N NN个整数A 1 , A 2 , ⋯ , A N A_1,A_2,\cdots,A_NA1,A2,⋯,AN。输出格式一个数为表达式的值。输入输出样例 #1输入 #12 1 2输出 #16说明/提示对于60 % 60\%60%的数据1 ≤ N ≤ 10 3 1 \le N \le 10^31≤N≤103对于100 % 100\%100%的数据1 ≤ N ≤ 10 5 1 \le N \le 10^51≤N≤1050 ≤ A i ≤ 10 9 0 \le A_i \le 10^90≤Ai≤109。C实现#includeiostream#includecstdio#includecstdlib#includecstring#includestring#includealgorithm#includemath.husingnamespacestd;intn,a,dp[32];longlongans;intmain(){inti,j;scanf(%d,n);for(i1;in;i){scanf(%d,a);for(j31;j-1;--j){if(a(1j))dp[j]i-dp[j];ans1LL*dp[j]*(1j);}}printf(%lld,ans);return0;}后续接下来我会不断用C来实现信奥比赛中的算法题、GESP考级编程题实现、白名单赛事考题实现记录日常的编程生活、比赛心得感兴趣的请关注我后续将继续分享相关内容