2014-06-10 23:50:45
题意&思路:直接模拟,处理进制时注意取模
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main(){ int Base,d,f,t,c,cnt; while(scanf("%d %d %d",&Base,&d,&f) == 3){ for(cnt = 1,c = 0,t = d;;){ t = (t * f) + c; c = t / Base; t = t % Base; if(c || t != d) ++cnt; else break; } printf("%d\n",cnt); } return 0; }
本文介绍了一个关于进制转换的模拟算法实现。该算法通过直接模拟的方式处理不同进制之间的转换,并特别关注了取模操作的重要性。代码示例展示了如何计算从一种进制到另一种进制转换时所需的步骤。
152

被折叠的 条评论
为什么被折叠?



