Jeffrey&Lynny

一个温馨小家庭的.Net生活

导航

USACO: Section 1.3 -- PROB Prime Cryptarithm

Source Code 

Lesson Learned: 
1. The pseudocode programming is the most important part. Once this part is done correctly, coding is trivial.
2. For the multiply and add math operations, if the oprands are not too large, it is more convenient and efficient to store them in a single integer instead of in an array. However, if they exceed the int value range(which is called large intergers), using an array is necessary.
3. Simple Algorithm Pattern: Moving an array backward one position should start from the last item instead of the first item.
4. Simple Algorithm Pattern(Big integer array add operation):
int advanceVal=0;
for(int i=0;i<len;i++)
{
 int addVal = b1[i]+b2[i]+advanceVal;
 c[i] = addVal%10;
 advanceVal = addVal/10;
}
c[len]=advanceVal;

posted on 2008-06-29 17:00  比尔盖房  阅读(303)  评论(0编辑  收藏  举报