首页 > 代码库 > 【HDOJ】1930 And Now, a Remainder from Our Sponsor
【HDOJ】1930 And Now, a Remainder from Our Sponsor
简单字符串。
1 #include <stdio.h> 2 3 #define MAXLEN 160 4 5 char buf[MAXLEN]; 6 int keys[4], parts[4]; 7 8 void getpart(int x) { 9 int i; 10 for (i=3; i>=0; --i) { 11 parts[i] = x%100; 12 x /= 100; 13 } 14 } 15 16 int main() { 17 int case_n, n, max, mm; 18 int i, j, k, flag, tmp, len; 19 20 scanf("%d", &case_n); 21 while (case_n--) { 22 scanf("%d", &n); 23 max = 0; 24 for (i=0; i<4; ++i) { 25 scanf("%d",&keys[i]); 26 if (max < keys[i]) { 27 max = keys[i]; 28 mm = i; 29 } 30 } 31 len = 0; 32 for (i=0; i<n; ++i) { 33 scanf("%d", &tmp); 34 getpart(tmp); 35 for (j=10000;;++j) 36 if (j%max == parts[mm]) 37 break; 38 while (1) { 39 flag = 1; 40 for (k=0; k<4; ++k) { 41 if (k == mm) continue; 42 if (j%keys[k] != parts[k]) { 43 flag = 0; 44 break; 45 } 46 } 47 if (flag) break; 48 j += max; 49 } 50 getpart(j); 51 for (k=1; k<4; ++k) { 52 if (parts[k] == 27) 53 buf[len++] = ‘ ‘; 54 else 55 buf[len++] = (char)(parts[k])+‘A‘-1; 56 } 57 } 58 while (buf[--len] == ‘ ‘) ; 59 buf[len+1] = ‘\0‘; 60 printf("%s\n", buf); 61 } 62 63 return 0; 64 }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。