OUC 假期
Posted lightac
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OUC 假期相关的知识,希望对你有一定的参考价值。
一道数学题,乘以ai - aj 用平方差,O(n)解决
#include<bits/stdc++.h> #define MAX 300010 using namespace std; typedef long long ll; ll a[MAX]; int main() ios::sync_with_stdio(false); ll n,p,k; cin >> n >> p >> k; for(int i=1; i<=n; i++) cin >> a[i]; a[i]=(a[i]*a[i]%p*a[i]%p*a[i]%p-k*a[i]%p+p)%p; sort(a + 1, a + n + 1); ll temp = 0, ans = 0; for(int i = 2; i <= n; i++) if(a[i-1] == a[i]) temp++; ans+=temp; else temp=0; cout << ans << endl; return 0;
以上是关于OUC 假期的主要内容,如果未能解决你的问题,请参考以下文章