-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ramjeet saran
committed
Aug 21, 2015
1 parent
ec678fc
commit ae38348
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//DATE: 20/08/2015 | ||
//Author: Ramjeet Saran | ||
//http://www.spoj.com/problems/CRDS/ | ||
|
||
#include <iostream> | ||
#include <stdio.h> | ||
#include <algorithm> | ||
#include <stack> | ||
#include <vector> | ||
#include <cmath> | ||
#include <cstring> | ||
#include <map> | ||
#include <string> | ||
|
||
# define MAX(a,b) a>b ? a : b; | ||
# define MIN(a,b) a<b ? a : b; | ||
# define lli long long int | ||
# define ull unsigned long long int | ||
# define FOR(i,j,n) for(i = j; i < n; i++) | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int t; | ||
lli n; | ||
cin>>t; | ||
while(t--){ | ||
cin>>n; | ||
lli ans = (3 * (( (n * (n - 1) ) / 2 ) % 1000007)) % 1000007; | ||
ans = ans + ( 2 * n ) % 1000007 ; | ||
cout<<ans%1000007<<endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//DATE: 20/08/2015 | ||
//Author: Ramjeet Saran | ||
//http://www.spoj.com/problems/LASTDIG2/ | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
#include <stack> | ||
#include <vector> | ||
#include <cmath> | ||
#include <cstring> | ||
|
||
int cycle[10] = {1,1,4,4,2,1,1,4,4,2}; | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
string a; | ||
long long int b; | ||
int t; | ||
cin>>t; | ||
while(t--){ | ||
cin>>a>>b; | ||
int lenA = a.length(); | ||
if(b == 0) | ||
cout<<"1"<<endl; | ||
else | ||
{ | ||
int x = a[lenA - 1] - '0'; | ||
int temp = b % cycle[x]; | ||
if(temp == 0) | ||
temp = cycle[x]; | ||
int power = 1; | ||
for(int i = 0; i < temp; i++) | ||
power *= x; | ||
cout<<power % 10<<endl; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//DATE: 20/08/2015 | ||
//Author: Ramjeet Saran | ||
//http://www.spoj.com/problems/MAXLN/ | ||
|
||
#include <iostream> | ||
#include <stdio.h> | ||
#include <algorithm> | ||
#include <stack> | ||
#include <vector> | ||
#include <cmath> | ||
#include <cstring> | ||
#include <map> | ||
#include <string> | ||
#include <iomanip> | ||
|
||
# define MAX(a,b) a>b ? a : b; | ||
# define MIN(a,b) a<b ? a : b; | ||
# define lli long long int | ||
# define ull unsigned long long int | ||
# define FOR(i,j,n) for(i = j; i < n; i++) | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int t; | ||
lli n; | ||
cin>>t; | ||
for(int i =1; i <= t; i++){ | ||
cin>>n; | ||
lli ans = 4 * n * n; | ||
cout<<"Case "<<i<<": "<<ans<<".25"<<endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//DATE: 20/08/2015 | ||
//Author: Ramjeet Saran | ||
//http://www.spoj.com/problems/OLOLO/ | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
#include <stack> | ||
#include <vector> | ||
#include <cmath> | ||
#include <cstring> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N; | ||
scanf("%d",&N); | ||
long long int A, ans = 0; | ||
while(N--){ | ||
scanf("%ld",&A); | ||
ans = ans ^ A; | ||
} | ||
printf("%ld\n",ans); | ||
|
||
} |