1. C, Axel Fiedler

/*
* ACM Programming Contest
*
* Problem: 10127 - Ones
* Status: Accepted
* Language: C
* Runtime: 0.004
* Date: 2009-07-05 18:51:38
* Author: Axel Fiedler
*
*/
#include <stdio.h>

int main()
{
int n, k, r;

while (scanf("%d", &n) != EOF)
{
k = 1;
r = (n == 1 ? 0 : 1);

while(r)
{
r = (r*10 + 1) % n;
k++;
}

printf("%d\n", k);
}

return 0;
}

2.

/*
 * ACM Programming Contest
 * Problem: 10127 (Ones)
 * Status: Accepted
 * Language: ANSI C
 * Runtime: 0.004
 * Date: 2009-07-07 20:21:35
 * Author: Andreas Kunft
 */

#include <stdio.h>

int number;
int a, r;
int main() {

while (scanf("%d", &number) != EOF) {
for (a = 1, r = number == 1 ? 0 : 1; r > 0; r = ((r * 10) + 1) % number, a++);
printf("%d\n", a);
}

return 0;
}