1 solutions
-
0
C :
#include<stdio.h> int trans(char c) { if (c>='0' && c<='9') return c-'0'; else return c-'a'+10; } int main() { int n, sum, i; char s[12]; //freopen("out.txt", "w", stdout); while (~scanf("%d",&n)) while (n--) { scanf("%s", s); sum = 0; if (s[0]=='0' && s[1]=='x') for (i=2; s[i]!='\0'; i++) sum=sum*16+trans(s[i]); else for (i=1; s[i]!='\0'; i++) sum=sum*8+s[i]-'0'; printf("%d\n", sum); } return 0; }
C++ :
#include <stdio.h> #include <time.h> #include <stdlib.h> int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); int t, d; while( ~scanf("%d", &t) ) { while( t-- ) { scanf("%i", &d), printf("%i\n", d); } } // srand((unsigned)time(0)); // printf("100100\n"); // for( int i = 0; i < 100100; ++i ) { // if( rand() % 2 == 0 ) { // int len = rand() % 7 + 1; // printf("0x"); // for( int j = 0; j < len; ++j ) { // int t = rand() % 16; // if( t > 9 ) putchar('a' + t - 10); // else printf("%d", t); // } // printf("\n"); // } // else { // int len = rand() % 10 + 1; // printf("0"); // for( int j = 0; j < len; ++j ) { // printf("%d", rand() % 8); // } // printf("\n"); // } // } return 0; }
- 1
Information
- ID
- 10005
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By