-
Notifications
You must be signed in to change notification settings - Fork 56
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
RryLee
committed
Feb 29, 2016
1 parent
b528626
commit 88d2bb3
Showing
24 changed files
with
697 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
char small[26] = {0}; | ||
char big[26] = {0}; | ||
int i, n; | ||
char s[1000]; | ||
while (scanf("%s", &s[strlen(s)]) == 1); | ||
n = strlen(s); | ||
for (int i = 0; i < n; i++) { | ||
if (s[i] >= 'a' && s[i] <= 'z') { | ||
small[s[i] - 'a'] = 1; | ||
} | ||
else if (s[i] >= 'A' && s[i] <= 'Z') { | ||
big[s[i] - 'A'] = 1; | ||
} | ||
} | ||
|
||
for (int i = 0; i < 26; i++) { | ||
if (!(big[i] == 1 || small[i] == 1)) { | ||
printf("not pangram"); | ||
return 0; | ||
} | ||
} | ||
|
||
printf("pangram"); | ||
|
||
return 0; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
$string = fgets($handle); | ||
|
||
$string = strtolower($string); | ||
|
||
$exists = true; | ||
|
||
foreach (range('a', 'z') as $c) { | ||
if (strpos($string, $c) === false) { | ||
$exists = false; | ||
break; | ||
} | ||
} | ||
|
||
echo ($exists ? "pangram" : "not pangram") . PHP_EOL; |
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,42 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%d", $T); | ||
|
||
while ($T --) { | ||
fscanf($handle, "%s", $str); | ||
|
||
$start = 0; | ||
$end = strlen($str) - 1; | ||
|
||
while ($start < $end) { | ||
if ($str[$start] == $str[$end]) { | ||
$start ++; | ||
$end --; | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
if ($start >= $end) { | ||
echo "-1\n"; | ||
continue; | ||
} | ||
|
||
$left = true; | ||
$start_temp = $start; | ||
$end_temp = $end; | ||
$start_temp ++; | ||
while ($start_temp < $end_temp) { | ||
if ($str[$start_temp] == $str[$end_temp]) { | ||
$start_temp ++; | ||
$end_temp --; | ||
} else { | ||
$left = false; | ||
break; | ||
} | ||
} | ||
|
||
echo $left ? $start : $end; | ||
echo "\n"; | ||
} |
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,5 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%s", $S); | ||
|
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,21 @@ | ||
#include<bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int t,i; | ||
cin>>t; | ||
while(t--) | ||
{ | ||
string str; | ||
cin>>str; | ||
int s = 0; | ||
for(i=0 ; i< str.length()/2 ; i++) | ||
{ | ||
s += abs(str[i] - str[str.length()-i-1]); | ||
} | ||
cout<<s<<endl; | ||
} | ||
return 0; | ||
} |
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,26 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%d", $T); | ||
|
||
while ($T --) { | ||
fscanf($handle, "%s", $S); | ||
|
||
$length = strlen($S); | ||
$start = 0; | ||
$end = $length - 1; | ||
$count = 0; | ||
while ($start < $end) { | ||
if ($S[$start] == $S[$end]) { | ||
$start ++; | ||
$end --; | ||
continue; | ||
} else { | ||
$count += abs(ord($S[$start]) - ord($S{$end})); | ||
$start ++; | ||
$end --; | ||
} | ||
} | ||
|
||
echo $count . PHP_EOL; | ||
} |
Binary file not shown.
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,36 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
string s1, s2; | ||
cin >> s1 >> s2; | ||
int length = s1.length(); | ||
int **array = new int*[length + 1]; | ||
for (int i = 0; i < length + 1; ++i) | ||
{ | ||
array[i] = new int[length + 1]; | ||
} | ||
|
||
for (int i = 0; i < length; ++i) | ||
{ | ||
for (int j = 0; j < length; ++j) | ||
{ | ||
if (s1[i] == s2[j]) | ||
{ | ||
array[i + 1][j + 1] = array[i][j] + 1; | ||
} | ||
else | ||
{ | ||
array[i + 1][j + 1] = max(array[i + 1][j], array[i][j + 1]); | ||
} | ||
} | ||
} | ||
|
||
cout << array[length][length] << endl; | ||
|
||
return 0; | ||
} |
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,35 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
string s, r; | ||
int times; | ||
cin >> times; | ||
|
||
for (int i = 0; i < times; ++i) | ||
{ | ||
cin >> s; | ||
int len = s.length(); | ||
|
||
bool funny = true; | ||
for (int j = 1; j < len; ++j) | ||
{ | ||
if (abs(s[len - j] - s[len - j - 1]) != abs(s[j] - s[j - 1])) { | ||
funny = false; | ||
break; | ||
} | ||
} | ||
|
||
if (funny) { | ||
cout << "Funny" << endl; | ||
} else { | ||
cout << "Not Funny" << endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
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,20 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%d", $T); | ||
|
||
for ($i=0; $i < $T; $i++) { | ||
$s = fgets($handle); | ||
$s = trim($s); | ||
$r = strrev($s); | ||
|
||
$funny = true; | ||
for ($j=1; $j < strlen($s); $j++) { | ||
if (abs(ord($s[$j]) - ord($s[$j - 1])) != abs(ord($r[$j]) - ord($r[$j - 1]))) { | ||
$funny = false; | ||
break; | ||
} | ||
} | ||
|
||
echo $funny ? "Funny\n" : "Not Funny\n"; | ||
} |
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,27 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int T; | ||
cin >> T; | ||
|
||
while (T --) { | ||
string str; | ||
cin >> str; | ||
|
||
int ans = 0; | ||
for (int i = 0; i < str.length() - 1; ++i) | ||
{ | ||
if (str[i] == str[i + 1]) | ||
ans ++; | ||
} | ||
|
||
cout << ans << endl; | ||
} | ||
|
||
return 0; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%d", $T); | ||
|
||
for ($i=0; $i < $T; $i++) { | ||
fscanf($handle, "%s", $str); | ||
|
||
$count = 0; | ||
for ($j=1; $j < strlen($str); $j++) { | ||
if ($str[$j] == $str[$j - 1]) { | ||
$count ++; | ||
} | ||
} | ||
|
||
echo $count . PHP_EOL; | ||
} |
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,37 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
string str; | ||
cin >> str; | ||
int A[26]; | ||
for (int i = 0; i < 26; ++i) | ||
{ | ||
A[i] = 0; | ||
} | ||
for (int i = 0; i < str.length(); ++i) | ||
{ | ||
A[str[i] - 'a'] ++; | ||
} | ||
|
||
int sum = 0; | ||
for (int i = 0; i < 26; ++i) | ||
{ | ||
sum = sum + (A[i] % 2); | ||
} | ||
|
||
if (sum >= 2) | ||
{ | ||
cout << "NO" << endl; | ||
} | ||
else | ||
{ | ||
cout << "YES" << endl; | ||
} | ||
|
||
return 0; | ||
} |
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,43 @@ | ||
<?php | ||
|
||
$handle = fopen("php://stdin", "r"); | ||
fscanf($handle, "%s", $str); | ||
|
||
$length = strlen($str); | ||
|
||
$flag = true; | ||
$some = []; | ||
|
||
for ($i=0; $i < $length; $i++) { | ||
$index = ord($str[$i]) - ord('a'); | ||
if (isset($some[$index])) { | ||
$some[$index] ++; | ||
} else { | ||
$some[$index] = 1; | ||
} | ||
} | ||
|
||
if ($length % 2 == 0) { | ||
foreach ($some as $a) { | ||
if ($a % 2 !== 0) { | ||
$flag = false; | ||
break; | ||
} | ||
} | ||
} else { | ||
$odd = 0; | ||
$even = 0; | ||
foreach ($some as $a) { | ||
if ($a % 2 !== 0) { | ||
$even ++; | ||
} else { | ||
$odd ++; | ||
} | ||
} | ||
|
||
if ($even != 1 || $odd == $length - 1) { | ||
$flag = false; | ||
} | ||
} | ||
|
||
echo $flag ? "YES\n" : "NO\n"; |
Oops, something went wrong.