-
Notifications
You must be signed in to change notification settings - Fork 814
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
Showing
6 changed files
with
39 additions
and
41 deletions.
There are no files selected for viewing
46 changes: 23 additions & 23 deletions
46
AdvancedLevel_C++/1019. General Palindromic Number (20).cpp
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
#include <cstdio> | ||
using namespace std; | ||
int main() { | ||
int a, b; | ||
scanf("%d %d", &a, &b); | ||
int arr[40], index = 0; | ||
while(a != 0) { | ||
arr[index++] = a % b; | ||
a = a / b; | ||
} | ||
int flag = 0; | ||
for(int i = 0; i < index / 2; i++) { | ||
if(arr[i] != arr[index-i-1]) { | ||
printf("No\n"); | ||
flag = 1; | ||
break; | ||
} | ||
} | ||
if(!flag) printf("Yes\n"); | ||
for(int i = index - 1; i >= 0; i--) { | ||
printf("%d", arr[i]); | ||
if(i != 0) printf(" "); | ||
} | ||
if(index == 0) | ||
printf("0"); | ||
return 0; | ||
int a, b; | ||
scanf("%d %d", &a, &b); | ||
int arr[40], index = 0; | ||
while(a != 0) { | ||
arr[index++] = a % b; | ||
a = a / b; | ||
} | ||
int flag = 0; | ||
for(int i = 0; i < index / 2; i++) { | ||
if(arr[i] != arr[index-i-1]) { | ||
printf("No\n"); | ||
flag = 1; | ||
break; | ||
} | ||
} | ||
if(!flag) printf("Yes\n"); | ||
for(int i = index - 1; i >= 0; i--) { | ||
printf("%d", arr[i]); | ||
if(i != 0) printf(" "); | ||
} | ||
if(index == 0) | ||
printf("0"); | ||
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
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 |
---|---|---|
|
@@ -29,7 +29,6 @@ int bfs(node tnode) { | |
} | ||
return cnt; | ||
} | ||
|
||
int main() { | ||
scanf("%d %d", &n, &l); | ||
v.resize(n + 1); | ||
|
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
using namespace std; | ||
int Data[100005], Next[100005], list[100005]; | ||
int main() { | ||
int first, k, n, temp; | ||
cin >> first >> n >> k; | ||
int data[100005], next[100005], list[100005]; | ||
for (int i = 0; i < n; i++) { | ||
cin >> temp; | ||
cin >> data[temp] >> next[temp]; | ||
cin >> Data[temp] >> Next[temp]; | ||
} | ||
int sum = 0;//不一定所有的输入的结点都是有用的,加个计数器 | ||
int sum = 0;//不⼀定所有的输⼊的结点都是有⽤的,加个计数器 | ||
while (first != -1) { | ||
list[sum++] = first; | ||
first = next[first]; | ||
first = Next[first]; | ||
} | ||
for (int i = 0; i < (sum - sum % k); i += k) | ||
reverse(begin(list) + i, begin(list) + i + k); | ||
for (int i = 0; i < sum - 1; i++) | ||
printf("%05d %d %05d\n", list[i], data[list[i]], list[i + 1]); | ||
printf("%05d %d -1", list[sum - 1], data[list[sum - 1]]); | ||
printf("%05d %d %05d\n", list[i], Data[list[i]], list[i + 1]); | ||
printf("%05d %d -1\n", list[sum - 1], Data[list[sum - 1]]); | ||
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