CRDS - Cards - SPOJ Solution C++

  Problem Link : CRDS 


👉 Hint : edit please

 


✅ C++ Solution :

 
#include<bits/stdc++.h>
using namespace std;
long long int m=1000007;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long int n,i,ans=0;
		cin>>n;
		ans=(n*(n+1)/2)%m;
		ans=(3*ans)%m;
		ans=(ans-n+m)%m;
		cout<<ans<<endl;
	}
	return 0;
}

 

Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook. 

😇Happy Learning!!