0分

P2084 进制转换

a[i]=b[n-i-1]-48; [评测记录](https://www.luogu.org/recordnew/show/15916869) 你扫b的时候方向反了
by TNoName @ 2019-01-30 16:52:06


@[yzc358230151](/space/show?uid=171427) 字符串从第一位开始枚举QAQ ``` #include <stdio.h> #include <string.h> int n,m,a[10000001]; char b[10000001]; int flag=1; int main() { scanf("%d %s",&m,b); n=strlen(b); for(int i=0;i<n;i++) { a[i]=b[i]-48; if(a[i]) { if(flag) {printf("%d*%d^%d",a[i],m,n-i-1);flag=0;} else printf("+%d*%d^%d",a[i],m,n-i-1); } } }```
by qian_shang @ 2019-01-30 16:54:46


现代码 ```cpp #include <stdio.h> #include <string.h> int n=1,m,a[1001]; char b[1001]={}; //string str; int main() { //freopen("testdata(1).in","r",stdin); scanf("%d %s",&m,b); for(int i=strlen(b)-1,j=0,flag=1;i>=0;i--,j++){ if(b[i]-48) { if(flag){printf("%c*%d^%d",b[j],m,i);flag=0;} else printf("+%c*%d^%d",b[j],m,i); } } //freopen("testdata(1).out","r",stdin) } ``` 仍然zero point......
by yzc358230151 @ 2019-01-30 17:27:22


现代码 #include <stdio.h> #include <string.h> int n=1,m,a[1001]; char b[1001]={}; //string str; int main() { //freopen("testdata(1).in","r",stdin); scanf("%d %s",&m,b); for(int i=strlen(b)-1,j=0,flag=1;i>=0;i--,j++){ if(b[i]-48) { if(flag){printf("%c*%d^%d",b[j],m,i);flag=0;} else printf("+%c*%d^%d",b[j],m,i); } } //freopen("testdata(1).out","r",stdin) } 仍然(1<0)分
by yzc358230151 @ 2019-01-30 17:28:26


现代码 ```cpp #include <stdio.h> #include <string.h> int n=1,m,a[1001]; char b[1001]={}; //string str; int main() { //freopen("testdata(1).in","r",stdin); scanf("%d %s",&m,b); for(int i=strlen(b)-1,j=0,flag=1;i>=0;i--,j++){ if(b[i]-48) { if(flag){printf("%c*%d^%d",b[j],m,i);flag=0;} else printf("+%c*%d^%d",b[j],m,i); } } //freopen("testdata(1).out","r",stdin) } ``` 仍然(1<0)分
by yzc358230151 @ 2019-01-30 17:29:09


附:c++版 ```cpp #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n=1,m,a[1001]; char b[1001]={}; //string str; int main() { //freopen("testdata(1).in","r",stdin); cin<<m; scanf("%s",b); for(int i=strlen(b)-1,j=0,flag=1;i>=0;i--,j++){ if(b[i]-48) { if(flag){cout<<b[j]<<'*'<<m<<'^'<<i;flag=0;} else cout<<'+'<<b[j]<<'*'<<m<<'^'<<i; } } //freopen("testdata(1).out","r",stdin) } ```
by yzc358230151 @ 2019-01-30 17:40:51


现 ```cpp #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n=1,m,a[1001]; char b[1001]={}; //string str; int main() { //freopen("testdata(1).in","r",stdin); cin>>m; scanf("%s",b); for(int i=strlen(b)-1,j=0,flag=1;i>=0;i--,j++){ if(b[i]-48) { if(flag){cout<<b[j]<<'*'<<m<<'^'<<i;flag=0;} else cout<<'+'<<b[j]<<'*'<<m<<'^'<<i; } } //freopen("testdata(1).out","r",stdin) } ```
by yzc358230151 @ 2019-01-30 17:42:47


|