Skip to content

Commit

Permalink
added crds,lastdig2,maxln,ololo
Browse files Browse the repository at this point in the history
  • Loading branch information
ramjeet saran committed Aug 21, 2015
1 parent ec678fc commit ae38348
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Readme
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ http://www.spoj.com/users/raj94/
32) NGM
33) BISHOPS
34) BEENUMS
35) OFFSIDE
36) CRDS
37) LASTDIG2
38) MAXLN
39) OLOLO
34 changes: 34 additions & 0 deletions crds.cpp
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;
}
}
38 changes: 38 additions & 0 deletions lastdig2.cpp
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;
}
}
}
34 changes: 34 additions & 0 deletions maxln.cpp
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;
}
}
24 changes: 24 additions & 0 deletions ololo.cpp
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);

}

0 comments on commit ae38348

Please sign in to comment.